private async void onButtonClick(object sender, RoutedEventArgs e) { var dialog = new MessageDialog("当前设置尚未保存,你确认要退出该页面吗?" ,"消息提示"); dialog.Commands.Add(new UICommand("确定", cmd => { }, commandId: 0)); dialog.Commands.Add(new UICommand("取消", cmd => { }, commandId: 1)); //设置默认按钮,不设置的话默认的确认按钮是第一个按钮 dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; //获取返回值 var result = await dialog.ShowAsync(); }
这篇文档对您是否有帮助?