using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace PDF_Master.Views.HomePanel
{
///
/// HomeGuidContent.xaml 的交互逻辑
///
public partial class HomeGuidContent : UserControl
{
public HomeGuidContent()
{
InitializeComponent();
}
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
e.Handled = true;
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
{
RoutedEvent = UIElement.MouseWheelEvent,
Source = sender
};
var listView = FindChild(sender as DependencyObject);
listView.RaiseEvent(eventArg);
}
private static T FindChild(DependencyObject parent) where T : DependencyObject
{
if (parent == null) return null;
var foundChild = default(T);
var childCount = VisualTreeHelper.GetChildrenCount(parent);
for (var i = 0; i < childCount; i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
if (child is T t)
{
foundChild = t;
break;
}
foundChild = FindChild(child);
if (foundChild != null) break;
}
return foundChild;
}
}
}