private async void ButtonDelete_Click(object sender, RoutedEventArgs e) { if (GridViewBook.SelectedItem != null) { try { ProgressBar.IsIndeterminate = true; ProgressBar.Visibility = Visibility.Visible; String id = ((GridViewBook.SelectedItem as Book).BookId).ToString(); string result = await webService.DeleteBookAsync(id); if (result != null) { MessageDialog messageDialog = new MessageDialog("Delete successfully!"); await messageDialog.ShowAsync(); Reset(); } else { MessageDialog messageDialog = new MessageDialog("Can't delete!"); await messageDialog.ShowAsync(); } getBook(); } catch (Exception ex) { MessageDialog messageDialog = new MessageDialog(ex.Message); await messageDialog.ShowAsync(); ProgressBar.Visibility = Visibility.Collapsed; ProgressBar.IsIndeterminate = false; } } else { MessageDialog messageDialog = new MessageDialog("Choise record to delete!"); await messageDialog.ShowAsync(); } }