private static void ExecuteDataGridDoubleClick(object sender, MouseButtonEventArgs args) { DataGrid @this = sender as DataGrid; ICommand cmd; if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { cmd = @this?.GetValue(DataGridDoubleClickWithModifierProperty) as ICommand; } else { cmd = @this?.GetValue(DataGridDoubleClickProperty) as ICommand; } if (cmd == null) { return; } DataGridRow row = VisualTreeHelpers.FindAncestor <DataGridRow>(args.OriginalSource as DependencyObject); object parameter = row?.DataContext ?? @this.SelectedItem; if (cmd.CanExecute(parameter)) { cmd.Execute(parameter); } }
private static void Element_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { if ((Keyboard.Modifiers & ModifierKeys.Control) != 0) { // Raise to top window var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) { RoutedEvent = UIElement.MouseWheelEvent, Source = sender }; var parent = VisualTreeHelpers.FindAncestor <Window>(sender as DependencyObject); parent?.RaiseEvent(eventArg); } }