2013-05-03 69 views
0

考慮以下頁面:文本框上下文菜單中顯示防止AppBar

<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內置的上下文菜單,阻止激活欄。只有當程序剛剛啓動,並且文本框中沒有任何操作時,應用程序欄可以通過右鍵單擊來激活。

有沒有什麼辦法在這種情況下顯示應用程序欄?

回答

1

您可以使用ContextMenuOpening事件TextBox。在這種情況下打開底部欄。

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. 
}