Skip to content

Set focus of PasswordBox #2803

Answered by AndrewKeepCoding
DFFspace asked this question in Q&A
Discussion options

You must be logged in to vote

You can use the Loaded event and call the Focus method there.

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
        this.Loaded += MainPage_Loaded;
    }

    private void MainPage_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
    {
        this.MyPassswordBox.Focus(Microsoft.UI.Xaml.FocusState.Programmatic);
    }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DFFspace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants