diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index 16b01e4..64235d5 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -247,6 +247,7 @@ ThemeComponentSelectionControl.xaml + diff --git a/Filtration/Utility/VisualTreeUtility.cs b/Filtration/Utility/VisualTreeUtility.cs new file mode 100644 index 0000000..79ddec4 --- /dev/null +++ b/Filtration/Utility/VisualTreeUtility.cs @@ -0,0 +1,26 @@ +using System.Windows; +using System.Windows.Media; + +namespace Filtration.Utility +{ + public class VisualTreeUtility + { + public static T FindParent(DependencyObject child) + where T : DependencyObject + { + //get parent item + var parentObject = VisualTreeHelper.GetParent(child); + + //we've reached the end of the tree + if (parentObject == null) return null; + + //check if the parent matches the type we're looking for + if (parentObject is T parent) + { + return parent; + } + + return FindParent(parentObject); + } + } +} diff --git a/Filtration/Views/ItemFilterBlockView.xaml.cs b/Filtration/Views/ItemFilterBlockView.xaml.cs index e830756..59f51df 100644 --- a/Filtration/Views/ItemFilterBlockView.xaml.cs +++ b/Filtration/Views/ItemFilterBlockView.xaml.cs @@ -2,6 +2,8 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using Filtration.UserControls; +using Filtration.Utility; namespace Filtration.Views { @@ -41,6 +43,14 @@ namespace Filtration.Views // up and down in ItemFilterScriptView rather than within the block. if (sender is ScrollViewer viewer && !e.Handled) { + // Don't handle events if they originated from a control within an EditableListBoxControl + // since we still want to allow scrolling within those with the mouse wheel + if (e.OriginalSource is DependencyObject dependencyObject && VisualTreeUtility.FindParent(dependencyObject) != null) + { + e.Handled = false; + return; + } + e.Handled = true; var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {RoutedEvent = MouseWheelEvent, Source = viewer};