更改MessageDialog内容或从MessageDialog处理程序Windows Store应用显示新内容

编程入门 行业动态 更新时间:2024-10-11 21:31:31
本文介绍了更改MessageDialog内容或从MessageDialog处理程序Windows Store应用显示新内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有MessageDialog对话框负责删除确认.

I have MessageDialog dialogue responsible for delete confirmation.

private async void ShowDialogClick(object sender, RoutedEventArgs e) { MessageDialog md = new MessageDialog("Are your sure you want to delete this?"); md.Commands.Add(new UICommand("Delete", new UICommandInvokedHandler(DeleteItemHandler))); md.Commands.Add(new UICommand("Cancel")); await md.ShowAsync(); }

当用户单击Delete时,DeleteItemHandler会调用数据库上的操作,但是如何通知用户操作不成功?

When user clicks Delete, DeleteItemHandler invokes operation on database, but how can I inform user about unsuccessful operation?

我试图创建新的MessageDialog,但是得到了win32 exception.

I tried to create new MessageDialog, but I got win32 exception.

private async void DeleteItemHandler(IUICommand command) { MessageDialog md = new MessageDialog("New content"); String result = DbDeletation(); if(result != "OK") await md.ShowAsync(); }

通知用户有关错误的最佳方法是什么?

What is the best way to inform user about error?

推荐答案

根据 Windows Store App准则 MessagegDialog并不是确认删除的好方法.

According to Windows Store App guidelines MessagegDialog isn't good way to confirm delete.

当应用需要确认用户对用户采取的操作的意图时,弹出按钮是合适的表面.请参阅弹出按钮准则.

When the app needs to confirm the user's intention for an action that the user has taken, a flyout is the appropriate surface. See Guidelines for flyouts.

现在我的代码更干净了...

Now I've cleaner code...

private async void DeleteItem_Click(object sender, RoutedEventArgs e) { MessageDialog md = new MessageDialog("Error"); String result = DbDeletation(); if (result != "OK") await md.ShowAsync(); }

然后轻轻地解决:)

<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Show Dialog"> <Button.Flyout> <Flyout> <StackPanel> <TextBlock>Are your sure you want to delte this?</TextBlock> <Button Click="DeleteItem_Click" Content="Delete" HorizontalAlignment="Right"/> </StackPanel> </Flyout> </Button.Flyout> </Button>

更多推荐

更改MessageDialog内容或从MessageDialog处理程序Windows Store应用显示新内容

本文发布于:2023-08-06 14:37:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1313021.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内容   程序   MessageDialog   Windows   Store

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!