Windows Phone 8.1 在消息对话框打开时覆盖后退按钮
本文关键字:覆盖 按钮 对话框 Phone 消息 Windows | 更新日期: 2023-09-27 17:56:33
我有一个消息对话框,显示两个按钮导航到页面 1 和导航到页面 2 按钮,这意味着我已限制用户导航到页面 1 或页面 2。
如果消息对话框打开并且后退按钮按下此行为关闭我的消息对话框,我遇到了问题。
我可以在消息对话框未打开的情况下覆盖后退按钮。 我想在对话框打开时覆盖后退按钮。
MessageDialog dlg = new MessageDialog("Are you sure you want to quit you will loose all your work ?", "Warning");
dlg.Commands.Add(new UICommand("nav-to-page1", new UICommandInvokedHandler(CommandHandler1)));
dlg.Commands.Add(new UICommand("nav-to-page2", new UICommandInvokedHandler(CommandHandler1)));
await dlg.ShowAsync();
任何帮助将不胜感激
默认关闭
消息对话框在按后键。不要认为您可以覆盖此行为,因为它不会在打开消息对话框时点击反向按键方法。一个建议:现在当你按下后退按钮时,它会将其作为命令并进入"CommandHandler1"方法。若要在创建命令时避免这种情况,请添加一些命令 id,例如
private async void gv_Tapped(object sender, TappedRoutedEventArgs e)
{
GridView gvi = sender as GridView;
MessageDialog dlg = new MessageDialog("Are you sure you want to quit you will loose all your work ?", "Warning");
dlg.Commands.Add(new UICommand("nav-to-page1", new UICommandInvokedHandler(CommandHandler1), 0));
dlg.Commands.Add(new UICommand("nav-to-page2", new UICommandInvokedHandler(CommandHandler1),1));
await dlg.ShowAsync();
}
private void CommandHandler1(IUICommand command)
{
// throw new NotImplementedException();
}