From 7cf2989905eab3d7b2a041133779ee9b3cc8df99 Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Fri, 5 Jun 2026 17:19:23 +0200 Subject: [PATCH] Mitigate issue by skipping animation when IsHitTestVisible == False --- .../Behaviors/Internal/TabControlHeaderScrollBehavior.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/MaterialDesignThemes.Wpf/Behaviors/Internal/TabControlHeaderScrollBehavior.cs b/src/MaterialDesignThemes.Wpf/Behaviors/Internal/TabControlHeaderScrollBehavior.cs index 7ad1d90b4f..aeecbf3706 100644 --- a/src/MaterialDesignThemes.Wpf/Behaviors/Internal/TabControlHeaderScrollBehavior.cs +++ b/src/MaterialDesignThemes.Wpf/Behaviors/Internal/TabControlHeaderScrollBehavior.cs @@ -336,13 +336,14 @@ private void AssociatedObject_ScrollChanged(object sender, ScrollChangedEventArg return; if ( _isAnimatingScroll || _desiredScrollStart is not { } desiredOffsetStart) return; + if (!TabControl.IsHitTestVisible) + return; double originalValue = desiredOffsetStart; double newValue = e.HorizontalOffset; _isAnimatingScroll = true; // HACK: Temporarily disable user interaction while the animated scroll is ongoing. This prevents the double-click of a tab stopping the animation prematurely. - bool originalIsHitTestVisibleValue = TabControl.IsHitTestVisible; TabControl.SetCurrentValue(FrameworkElement.IsHitTestVisibleProperty, false); AssociatedObject.ScrollToHorizontalOffset(originalValue); @@ -355,8 +356,8 @@ private void AssociatedObject_ScrollChanged(object sender, ScrollChangedEventArg _desiredScrollStart = null; _isAnimatingScroll = false; - // HACK: Set the hit test visibility back to its original value - TabControl.SetCurrentValue(FrameworkElement.IsHitTestVisibleProperty, originalIsHitTestVisibleValue); + // HACK: Re-enable hit test visibility + TabControl.SetCurrentValue(FrameworkElement.IsHitTestVisibleProperty, true); }; AssociatedObject.BeginAnimation(TabControlHeaderScrollBehavior.CustomHorizontalOffsetProperty, scrollAnimation); }