Fixed ScrollViewer event handling special casing

This commit is contained in:
Ben Wallis 2018-12-05 20:26:01 +00:00
parent 7c0da57570
commit 4052d6e020
1 changed files with 12 additions and 3 deletions

View File

@ -45,8 +45,8 @@ namespace Filtration.Views
{
// Don't handle events if they originated from a control within an EditableListBoxControl
// or a ComboBox since we still want to allow scrolling within those with the mouse wheel
if (e.OriginalSource is DependencyObject dependencyObject && (VisualTreeUtility.FindParent<EditableListBoxControl>(dependencyObject) != null ||
IsDropDownScrollViewer(dependencyObject)))
if (e.OriginalSource is DependencyObject dependencyObject && (IsDropDownScrollViewer(dependencyObject) || ParentIsEditableListBoxControl(dependencyObject) ||
ParentIsDropDownScrollViewer(dependencyObject)))
{
e.Handled = false;
return;
@ -62,10 +62,19 @@ namespace Filtration.Views
}
}
private bool IsDropDownScrollViewer(DependencyObject dependencyObject)
private static bool ParentIsEditableListBoxControl(DependencyObject dependencyObject)
{
return VisualTreeUtility.FindParent<EditableListBoxControl>(dependencyObject) != null;
}
private static bool ParentIsDropDownScrollViewer(DependencyObject dependencyObject)
{
var parent = VisualTreeUtility.FindParent<ScrollViewer>(dependencyObject);
return parent != null && parent.Name == "DropDownScrollViewer";
}
private static bool IsDropDownScrollViewer(DependencyObject dependencyObject)
{
return dependencyObject is ScrollViewer scrollViewer && scrollViewer.Name == "DropDownScrollViewer";
}
}
}