I have the following code:
<Page.BottomAppBar> <AppBar x:Name="MyAppBar" Height="32" IsOpen="True" Opened="MyAppBar_Opened"> <TextBox x:Name="SearchBar" Grid.Row="2" KeyDown="SearchBar_KeyDown"/> </AppBar> </Page.BottomAppBar>
The problem is that it has no focus when the application opens, it also has no focus when I double-click twice to close and reopen it.
Currently, I have the following code in MyAppBar_Opened and OnNavigatedTo :
if (MyAppBar == null) return; MyAppBar.Focus(Windows.UI.Xaml.FocusState.Keyboard); if (SearchBar == null) return; SearchBar.Focus(Windows.UI.Xaml.FocusState.Keyboard);
But this does not seem to have any effect; other enum values, such as Mouse or Programmatic , also do not work. What am I doing wrong that does not lead to activation?
I know an alternative that used to work, but the Metro FocusManager does not have a SetFocusedElement?
source share