本文介绍了更改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.
现在我的代码更干净了...
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应用显示新内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!