// Handles isChecked changed private static void OnIsCheckedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { bool newValue = (bool)e.NewValue; bool oldValue = (bool)e.OldValue; MenuItem button = (MenuItem)d; if (oldValue != newValue) { if (newValue) { if (button.Checked != null) { button.Checked(button, new RoutedEventArgs()); } } else { if (button.Unchecked != null) { button.Unchecked(button, new RoutedEventArgs()); } } } // Uncheck other toggle buttons if (newValue && button.GroupName != null) { foreach (MenuItem item in GetItemsInGroup(button.GroupName)) { if (item != button) { item.IsChecked = false; } } } }