Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/PerfView/EventViewer/EventWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
ToolTip="Click on Update button to update."
SelectionMode="Extended" SelectionUnit="CellOrRowHeader"
SelectedCellsChanged="SelectedCellsChanged"
PreviewMouseWheel="Grid_PreviewMouseWheel"
AlternatingRowBackground="{DynamicResource AlternateRowBackground}"
AutomationProperties.Name="Events Table"
ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}">
Expand Down
42 changes: 42 additions & 0 deletions src/PerfView/EventViewer/EventWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,7 @@ private void Add(ObservableCollection<EventRecord> events, EventRecord event_)
private List<DataGridColumn> m_userDefinedColumns;
private float[] m_buckets; // Keep track of the counts of events.
private double m_bucketTimeMSec; // Size for each bucket
private ScrollViewer m_gridScrollViewer; // Cached ScrollViewer for horizontal scrolling
#endregion

private void DoUseLocalTime(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -2001,5 +2002,46 @@ private void DoHideTimeStampColumns(object sender, RoutedEventArgs e)
// Save preference
App.UserConfigData["EventWindowShowTimeStampColumns"] = "false";
}

/// <summary>
/// When Shift is held, redirect mouse wheel events to horizontal scrolling.
/// </summary>
private void Grid_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (Keyboard.Modifiers == ModifierKeys.Shift)
{
// Cache the ScrollViewer on first use
if (m_gridScrollViewer == null)
{
m_gridScrollViewer = FindVisualChild<ScrollViewer>((DependencyObject)sender);
if (m_gridScrollViewer == null)
{
return;
}
}

m_gridScrollViewer.ScrollToHorizontalOffset(m_gridScrollViewer.HorizontalOffset - e.Delta);
e.Handled = true;
}
}

private static T FindVisualChild<T>(DependencyObject parent) where T : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(parent, i);
if (child is T found)
{
return found;
}

T result = FindVisualChild<T>(child);
if (result != null)
{
return result;
}
}
return null;
}
}
}