/// <summary> /// Deletes the given checkbox item. /// </summary> /// <param name="checkbox"></param> private void DeleteItems(object checkboxes) { IList boxes = (IList)checkboxes; if (boxes == null) { return; } List <CheckBox> convertedBoxes = new List <CheckBox>(boxes.Cast <CheckBox>()); // Loop around removing the checkboxes selected, but not if they're text is the default text. foreach (CheckBox box in convertedBoxes) { if (box.Content.ToString() == DefaultTODO) { continue; } CheckListList.Remove(box); } DataDealer.WriteChecklistData(CheckListItems); // Make sure that there's always a default todo if (CheckListList.Count <= 0) { CheckListList.Add(MakeCheckBoxForItem(DefaultTODO)); } string[] itemsDeleted = convertedBoxes.Select(checkbox => checkbox.Content.ToString()).ToList().ToArray(); // Fire the event. ItemsDeleted?.Invoke(this, itemsDeleted); }
public void RaiseItemsDeleted(List <T> items) { if (items != null) { ItemsDeleted?.Invoke(this, items); } }
public void DeleteItemRange(IEnumerable <KeyCollectionItem> items) { foreach (var item in items) { Items.Remove(item); } if (ItemsDeleted != null) { ItemsDeleted.Invoke(items); } }