/// <summary> /// Mouse wheel used /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DesignerScrollViewer_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e) { if (Keyboard.Modifiers != 0) { TableViewControl viewControl = e.Source as TableViewControl; if (viewControl != null) { try { var grid = viewControl.TableDataGrid; var item = grid.SelectedItem; var row = grid.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow; var cbox = VisualTreeHelperEx.FindDescendantByName(row, "DataTypeComboBox") as ComboBox; if (cbox != null) { cbox.IsDropDownOpen = false; } } catch (Exception exc) { Trace.WriteLine(exc.Message); } } } if ((Keyboard.Modifiers & ModifierKeys.Control) != 0) { double newScale = ViewModel.Scale; if (e.Delta > 0) { newScale += 0.05; } else if (e.Delta < 0) { newScale -= 0.05; } ViewModel.ChangeZoomCommand.Execute(newScale.ToString("G")); e.Handled = true; } else if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { DesignerScrollViewer.ScrollToHorizontalOffset(DesignerScrollViewer.HorizontalOffset + e.Delta); e.Handled = true; } }
public App() { InitializeComponent(); MainPage = new TableViewControl(); }