Reputation: 1453
I have a WPF application that has a tool bar then a content control that nests a grid that contains a Tabcontrol and a ScrollViewer that wraps a TabPanel.
The scrollviewer works great, but only if my mouse is hovering over the tab control. How can I get the scroll viewer to scroll as long as my cursor is in the window?
Upvotes: 2
Views: 673
Reputation: 2947
Try to capture the event in the Window and raise it in the TabControl, something around this (untested):
private void Window_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (!e.Handled)
{
e.Handled = true;
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
eventArg.RoutedEvent = MouseWheelEvent;
eventArg.Source = sender;
MyTabControl.RaiseEvent(eventArg);
}
}
Upvotes: 1