There are two TextBox elements and one Button in the markup. All this is placed in the StackPanel. When you start the application, the cursor flashes in the first TextBox element. Please tell me how to disable the automatic install focus.

<StackPanel x:Name="stack_Box" Canvas.ZIndex="2" Grid.Row="1" > <TextBox x:Name="textbox_Login" HorizontalAlignment="Center" Margin="0,20,0,0" Text="" VerticalAlignment="Top" Width="200" FontSize="20" GotFocus="textBox_Login_GotFocus" PlaceholderText="Логин"/> <TextBox x:Name="textbox_Password" HorizontalAlignment="Center" Margin="0,20,0,0" TextWrapping="NoWrap" VerticalAlignment="Bottom" Width="200" FontSize="20" GotFocus="textBox_Password_GotFocus" PlaceholderText="Пароль"/> <Button x:Name="button_Enter" Content="Войти" HorizontalAlignment="Center" Margin="0,20,0,0" VerticalAlignment="Bottom" Width="200" Canvas.ZIndex="2" FontSize="20" Foreground="White" /> </StackPanel> 
  • As a quick hack, put an invisible focusable element in the tab order first, and when the focus arrives, send this very focus to where you need it. - VladD
  • I did not understand your method very well. When focusing on TextBox Login or TextBox, my password should start an animation. When I run the application, the animation starts because the focus is already worth it. - AlfredBauer
  • Well, the point is that when you start, the focus goes to your invisible element, not the animated texbox. - VladD pm
  • It dawned on me what you meant. Quick hack turned out. Thank. - AlfredBauer
  • Okay, then I'll make out as an answer. - VladD

1 answer 1

(Removed from comments)

As a quick hack, place an invisible focusable element first in the tab order. Then when you start the application, this invisible element will receive focus instead of a textbox. When the focus arrives, you can either ship it to where you need it or leave it on this item.

If it is important to you in the tab order program, it makes sense to remove this invisible element as soon as the focus goes off. He fulfilled his role, and should not interfere.