A common task in UI development is setting the focus on a textbox when navigating to a particular screen. When doing this on a Windows 8 application, a lot of developers try to do this inside the OnNavigatedTo event handler. This does not work. To set the focus on a textbox when the page is hit, call the focus method on the particular textbox inside the loaded event handler… That should do it.
<common:LayoutAwarePage
x:Name="pageRoot"
…
Loaded="pageRoot_Loaded_1">
private void pageRoot_Loaded_1(object sender, RoutedEventArgs e)
{
this.txtName.Focus(FocusState.Programmatic);
}
Hope this helps. Happy Coding!
IceRocket Tags: Windows 8,Windows Store App,Metro Application,LayoutAwarePage,Textbox focus,set focus,FocusState,wpf,xaml,c#
No comments:
Post a Comment