public void AddItem(CheckActivity newItm) { if (newItm != null) { Items.Add(newItm); } }
private void Button_Click(object sender, RoutedEventArgs e) { Button thisButton = (Button)sender; if (null == thisButton) { return; } CheckActivity thsActivity = (CheckActivity)thisButton.DataContext; if (null == thsActivity) { return; } thsActivity.IsChecked = !thsActivity.IsChecked; if (thsActivity.IsChecked) { thsActivity.Name = "[✓]" + thsActivity.Name.Substring(3); } else { thsActivity.Name = "[ ]" + thsActivity.Name.Substring(3); } UpdateItems(); }
private void Delete_MenuItem_Click(object sender, RoutedEventArgs e) { Button MyButton = null; if (sender is MenuItem mnu) { ContextMenu MyContextMenu = (ContextMenu)mnu.Parent; MyButton = MyContextMenu.PlacementTarget as Button; } if (null == MyButton) { return; } CheckActivity thsActivity = (CheckActivity)MyButton.DataContext; if (null == thsActivity) { return; } Items.Remove(thsActivity); }