我有一个 WPF 应用程序,它有一个工具栏,然后是一个内容控件,它嵌套了一个网格,该网格包含一个 Tabcontrol 和一个包装 TabPanel 的 ScrollViewer。
滚动查看器效果很好,但前提是我的鼠标悬停在选项卡控件上。只要我的光标在窗口中,如何让滚动查看器滚动?
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);
}
}