private void btnDelete_Click(object sender, RoutedEventArgs e) { MySelectableListItem sel = lstTriggers.CurrentlySelected; if (sel != null) { Trigger trigger = ((object[])sel.CustomData)[1] as Trigger; int selectedIndex = lstTriggers.SelectedIndex; if (lstTriggers.isLastItemSelected()) { selectedIndex--; } lstTriggers.Remove(sel); Triggers.Delete(trigger); if (selectedIndex >= 0) // Select next item { lstTriggers.SelectedIndex = selectedIndex; } else // Category empty, regenerate catagories { updateLists(); } UnsavedChanges = true; } }
private void btnActDel_Click(object sender, RoutedEventArgs e) { MySelectableListItem sel = lstAct.CurrentlySelected; if (sel != null) { int selectedIndex = lstAct.SelectedIndex; if (lstAct.isLastItemSelected()) { selectedIndex--; } lstAct.Remove(sel); if (selectedIndex >= 0) // Select next item { lstAct.SelectedIndex = selectedIndex; } } TabControl_SelectionChanged(null, null); }