private static void OnKeyDown(object sender, KeyEventArgs e) { if (e.OriginalSource == sender && e.Key == Key.Space) { // ignore alt + space which invokes the system menu if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) { return; } VirtualToggleButton.UpdateIsChecked((DependencyObject)sender); e.Handled = true; } }
private static void UpdateIsChecked(DependencyObject d) { bool?isChecked = VirtualToggleButton.GetIsChecked(d); if (isChecked.HasValue == false) { VirtualToggleButton.SetIsChecked(d, false); } else if (isChecked == true) { VirtualToggleButton.SetIsChecked(d, false); } else if (isChecked == false) { VirtualToggleButton.SetIsChecked(d, true); } }
private static void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { e.Handled = true; VirtualToggleButton.UpdateIsChecked((DependencyObject)sender); }