public async void OnDeleteItemClick(object sender, RoutedEventArgs e) { if (Selected != null) { var dialog = new Windows.UI.Popups.MessageDialog( "Voulez vous supprimer le client ?", "Attention" ); dialog.Commands.Add(new Windows.UI.Popups.UICommand("Oui") { Id = 0 }); dialog.Commands.Add(new Windows.UI.Popups.UICommand("Non") { Id = 1 }); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var result = await dialog.ShowAsync(); if ((int)result.Id == 0) { try { if (await _api.DeleteCustomerWithRetryAsync(Selected.Id)) { CustomersItems.Remove(Selected); Selected = CustomersItems.FirstOrDefault(); OnPropertyChanged(nameof(IsViewState)); } else { var unknowErrorDialog = new Windows.UI.Popups.MessageDialog( "Une erreur est survenue", "Erreur"); unknowErrorDialog.Commands.Add(new Windows.UI.Popups.UICommand("Ok") { Id = 0 }); await unknowErrorDialog.ShowAsync(); } } catch (Exception ex) { var errorDialog = new Windows.UI.Popups.MessageDialog( ex.Message, "Erreur"); errorDialog.Commands.Add(new Windows.UI.Popups.UICommand("Ok") { Id = 0 }); await errorDialog.ShowAsync(); } } } }