Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
35 changes: 35 additions & 0 deletions src/PerfView/EventViewer/EventWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2001,5 +2001,40 @@ 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)
{
var scrollViewer = FindVisualChild<ScrollViewer>((DependencyObject)sender);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be cacheable so that you don't have to find it on each event.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a commit, let me know if this is what you meant by caching

if (scrollViewer != null)
{
scrollViewer.ScrollToHorizontalOffset(scrollViewer.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;
}
}
}