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();
}
When user clicks Delete
, DeleteItemHandler
invokes operation on database, but how can I inform user about unsuccessful operation?
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?
You can't customize MessageDialos and call them in a row, so, you have two ways:
Build your own Popup control with commands and do not close popup until the operation will return the result. Show progress or something like that. If error will happen - show it right in popup window.
Use MessageDialog and show progess and error messages(if any) in the place where you called MessageDialog (near the button
Delete
, for example).The second method fits Windows Store App guidelines a bit more.
According to Windows Store App guidelines
MessagegDialog
isn't good way to confirm delete.Now I've cleaner code...
And more gently solution :)