Skip to content
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
df185e4
PoC for hijacking RequestBringIntoView event
nicolaihenriksen Dec 9, 2025
8f02def
Improves tab header scrolling behavior
nicolaihenriksen Dec 9, 2025
0511117
Adding smooth/animated scrolling to the behavior
nicolaihenriksen Dec 9, 2025
721a25c
Ensure padding on tab headers is only applied when they overflow
nicolaihenriksen Dec 9, 2025
f631a2d
Adding UI tests without assertions to easily test behavior
nicolaihenriksen Dec 10, 2025
9cace11
Minor hack! Prevent double-click on tab (control) while animating
nicolaihenriksen Dec 10, 2025
7c0c9ee
Add TabAssist.AnimateTabScrolling to toggle tab switch animation feature
nicolaihenriksen Dec 10, 2025
c27cc43
Add TODO comment regarding destructive-read on TabScrollDirection AP
nicolaihenriksen Dec 10, 2025
d18d4d4
Add TabAssist.TabScrollOffset to give control of the offset
nicolaihenriksen Dec 10, 2025
4a960c0
Replace TabAssist.AnimateTabScrolling with TabAssist.TabScrollDuration
nicolaihenriksen Dec 10, 2025
9631e7a
Rename hijacking StackPanel
nicolaihenriksen Dec 14, 2025
f001a07
Rename TabScrollDirection
nicolaihenriksen Dec 14, 2025
737223f
Rename TabScrollOffset
nicolaihenriksen Dec 14, 2025
eb5d42d
Rename TabScrollDuration
nicolaihenriksen Dec 14, 2025
966c1e8
Remove debug output
nicolaihenriksen Dec 14, 2025
a604ccf
Add TabAssist.UseHeaderPadding to enable/disable new behavior
nicolaihenriksen Dec 14, 2025
0200ded
Change bring into view event listener to class handler
nicolaihenriksen Dec 21, 2025
a4512b4
Implement "destructive read" of TabScrollDirection
nicolaihenriksen Dec 21, 2025
eca4a48
Mitigate quick keypresses causing tab animation to stop
nicolaihenriksen Dec 21, 2025
fe5b943
Use tab animation even when tab has focusable content
nicolaihenriksen Dec 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change bring into view event listener to class handler
This is to avoid a potential handler leak
  • Loading branch information
nicolaihenriksen committed Dec 21, 2025
commit 0200ded4fa2b23bd7cfa1224e9e8416e445ef313
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


using MaterialDesignThemes.Wpf.Behaviors.Internal;

namespace MaterialDesignThemes.Wpf.Internal;
Expand Down Expand Up @@ -34,27 +34,31 @@ public bool UseHeaderPadding
public static readonly DependencyProperty UseHeaderPaddingProperty =
DependencyProperty.Register(nameof(UseHeaderPadding), typeof(bool), typeof(PaddedBringIntoViewStackPanel), new PropertyMetadata(false));

public PaddedBringIntoViewStackPanel()
=> AddHandler(FrameworkElement.RequestBringIntoViewEvent, new RoutedEventHandler(OnRequestBringIntoView), false);
static PaddedBringIntoViewStackPanel()
=> EventManager.RegisterClassHandler(typeof(PaddedBringIntoViewStackPanel),
FrameworkElement.RequestBringIntoViewEvent,
new RequestBringIntoViewEventHandler(OnRequestBringIntoView));

private void OnRequestBringIntoView(object sender, RoutedEventArgs e)
private static void OnRequestBringIntoView(object sender, RoutedEventArgs e)
{
if (!UseHeaderPadding)
var panel = (PaddedBringIntoViewStackPanel)sender;
if (!panel.UseHeaderPadding)
return;

if (e.OriginalSource is FrameworkElement child && child != this)
if (e.OriginalSource is FrameworkElement child && child != panel)
{
e.Handled = true;

// TODO: Consider making the "ScrollDirection" a destructive read (i.e. reset the value once it is read) to avoid leaving a Backward/Forward value that may be misinterpreted at a later stage.
double offset = ScrollDirection switch {
TabScrollDirection.Backward => -HeaderPadding,
TabScrollDirection.Forward => HeaderPadding,
double offset = panel.ScrollDirection switch
{
TabScrollDirection.Backward => -panel.HeaderPadding,
TabScrollDirection.Forward => panel.HeaderPadding,
_ => 0
};
var point = child.TranslatePoint(new Point(), this);
var point = child.TranslatePoint(new Point(), panel);
var newTargetRect = new Rect(new Point(point.X + offset, point.Y), child.RenderSize);
BringIntoView(newTargetRect);
panel.BringIntoView(newTargetRect);
}
}
}