私は次のコードを持っています:
<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>
問題は、アプリケーションを開いたときにフォーカスがないことです。また、2回右クリックして閉じてから、もう一度開いたときにフォーカスがありません。
私は現在、との両方に次のコードを持っていMyAppBar_Opened
ますOnNavigatedTo
:
if (MyAppBar == null)
return;
MyAppBar.Focus(Windows.UI.Xaml.FocusState.Keyboard);
if (SearchBar == null)
return;
SearchBar.Focus(Windows.UI.Xaml.FocusState.Keyboard);
しかし、それは効果がないようです。他の列挙値は、同様に機能するMouse
か、Programmatic
機能しません。何が間違っているので、アクティベーションができませんか?
以前は機能していた代替手段を知っていますが、Metro FocusManagerにはSetFocusedElementがありませんか?