private void AssociatedObject_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
this.AssociatedObject.GetVisualContainer().ScrollOwner.PreviewMouseLeftButtonDown += ScrollOwner_PreviewMouseLeftButtonDown;
}
private void ScrollOwner_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
RepeatButton repeatButton = null;
object value = null;
var source = e.OriginalSource;
while (repeatButton == null && source != null)
{
var parent = source.GetType().GetProperty("InternalVisualParent", BindingFlags.Instance | BindingFlags.NonPublic);
value = parent.GetValue(source);
source = value;
repeatButton = value as RepeatButton;
}
if (repeatButton != null)
{
var name = ((RoutedCommand)repeatButton.Command).Name;
if (name == "LineUp")
{
for (int i = 1; i < 10; i++)
this.AssociatedObject.GetVisualContainer().LineUp();
}
else if (name == "LineDown")
{
for (int i = 1; i < 10; i++)
this.AssociatedObject.GetVisualContainer().LineDown();
}
}
} |
private void ScrollOwner_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
RepeatButton repeatButton = null;
object value = null;
var source = e.OriginalSource;
while (repeatButton == null && source != null)
{
var parent = source.GetType().GetProperty("InternalVisualParent", BindingFlags.Instance | BindingFlags.NonPublic);
value = parent.GetValue(source);
source = value;
repeatButton = value as RepeatButton;
}
if (repeatButton != null)
{
var name = ((RoutedCommand)repeatButton.Command).Name;
if (name == "LineUp" || name=="PageUp")
{
for (int i = 0; i < 10; i++)
this.AssociatedObject.GetVisualContainer().LineUp();
e.Handled = true;
}
else if (name == "LineDown" || name=="PageDown")
{
for (int i = 0; i < 10; i++)
this.AssociatedObject.GetVisualContainer().LineDown();
e.Handled = true;
}
}
} |