Set focus of PasswordBox #2803
-
I was wondering if there is any sort of way to make the PasswordBox focussed (always highlighted) on the main page. At the moment I have to click in the box to make it Focus and when switching to settings and than back to the main page it lost focus. |
Beta Was this translation helpful? Give feedback.
Answered by
AndrewKeepCoding
Aug 2, 2022
Replies: 1 comment
-
You can use the 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);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
DFFspace
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the
Loaded
event and call theFocus
method there.