C# 文本框上下文菜单阻止显示AppBar
考虑下一页:C# 文本框上下文菜单阻止显示AppBar,c#,xaml,windows-store-apps,C#,Xaml,Windows Store Apps,考虑下一页: <Page ... > <Grid> <TextBox AcceptsReturn="True" /> </Grid> <Page.BottomAppBar> <AppBar> <Grid> <StackPanel Orientation="Horizontal"> <Button Conte
<Page ... >
<Grid>
<TextBox AcceptsReturn="True" />
</Grid>
<Page.BottomAppBar>
<AppBar>
<Grid>
<StackPanel Orientation="Horizontal">
<Button Content="Test 1" />
<Button Content="Test 2" />
</StackPanel>
</Grid>
</AppBar>
</Page.BottomAppBar>
</Page>
这是文本框和底部应用程序栏。现在,当我在桌面计算机上运行这个商店应用程序时,我知道激活该栏的唯一方法是在窗口中单击鼠标右键。但是,将显示TextBox内置的上下文菜单,以防止激活栏。只有当程序刚刚启动,并且文本框中没有任何操作时,应用程序栏才能通过右键单击激活
在这种情况下,有没有办法显示应用程序栏?您可以使用
TextBox
的ContextMenuOpening
事件。在该事件中打开底部栏
private void TextBox_ContextMenuOpening_1(object sender, ContextMenuEventArgs e)
{
BottomAppBar.IsOpen = true;
e.Handled = true; //True only if you don't want to show context menu of textbox.
}