private void DeleteActionButton_Click(object sender, RoutedEventArgs e) { if (ActionsViewListBox.SelectedItem == null) { return; } if (MetroMessageBox.Show("Вы действительно хотите удалить выбранное действие?", "Удаление", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var actionTypeId = Convert.ToInt32(ActionsViewListBox.SelectedValue); _ac.DeleteAction(actionTypeId); //Refill items source ActionsViewListBox.ItemsSource = GetDetailActionView(); if (ActionsViewListBox.HasItems) { ActionsViewListBox.SelectedIndex = 0; } } }