/// <summary> /// Se aplica cada vez que se quiere eliminar un guest en el grid presionando la tecla Delete /// </summary> /// <history> /// [jorcanche] created 05/05/2016 /// </history> private async void dgGuestPremanifest_PreviewKeyDown(object sender, KeyEventArgs e) { var row = dgGuestPremanifest.SelectedItem as GuestPremanifestOuthouse; //Si no es una tecla Delete ó si row es igual a null Retornamos if (e.Key != Key.Delete || row == null) { return; } // Si se esta editando alguna celda del row no dejamos que elimine el registro if (((DataGridRow)dgGuestPremanifest.ItemContainerGenerator.ContainerFromItem(row)).IsEditing) { return; } //Si se presiono la tecla Delte y si diferente de Null el row y si tiene Show el guest //No lo permitimos eliminar y retornamos if (row.guShow) { e.Handled = true; UIHelper.ShowMessage("You can not delete the Guest because has 'Show Up'"); return; } var result = UIHelper.ShowMessage("Are you sure you want to delete this invitation?", MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { await BRGuests.DeleteGuest(row.guID); } else { e.Handled = true; } }