Skip to content
Open
Show file tree
Hide file tree
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
Rename TabScrollDirection
  • Loading branch information
nicolaihenriksen committed Dec 14, 2025
commit f001a07781354c6acd9c4d103775a687748a77d8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Windows.Media.Animation;
using Microsoft.Xaml.Behaviors;

Expand All @@ -17,11 +17,11 @@ private static void CustomHorizontalOffsetChanged(DependencyObject d, Dependency
scrollViewer.ScrollToHorizontalOffset((double)e.NewValue);
}

public static readonly DependencyProperty TabScrollDirectionProperty =
DependencyProperty.RegisterAttached("TabScrollDirection", typeof(TabScrollDirection),
public static readonly DependencyProperty ScrollDirectionProperty =
DependencyProperty.RegisterAttached("ScrollDirection", typeof(TabScrollDirection),
typeof(TabControlHeaderScrollBehavior), new PropertyMetadata(TabScrollDirection.Unknown));
public static TabScrollDirection GetTabScrollDirection(DependencyObject obj) => (TabScrollDirection)obj.GetValue(TabScrollDirectionProperty);
public static void SetTabScrollDirection(DependencyObject obj, TabScrollDirection value) => obj.SetValue(TabScrollDirectionProperty, value);
public static TabScrollDirection GetScrollDirection(DependencyObject obj) => (TabScrollDirection)obj.GetValue(ScrollDirectionProperty);
public static void SetScrollDirection(DependencyObject obj, TabScrollDirection value) => obj.SetValue(ScrollDirectionProperty, value);

public TabControl TabControl
{
Expand Down Expand Up @@ -75,7 +75,7 @@ private void OnTabChanged(object sender, SelectionChangedEventArgs e)
if (e.AddedItems.Count > 0)
{
_desiredScrollStart = AssociatedObject.ContentHorizontalOffset;
SetTabScrollDirection(tabControl, (IsMovingForward() ? TabScrollDirection.Forward : TabScrollDirection.Backward));
SetScrollDirection(tabControl, (IsMovingForward() ? TabScrollDirection.Forward : TabScrollDirection.Backward));
}

bool IsMovingForward()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace MaterialDesignThemes.Wpf.Internal;

public class PaddedBringIntoViewStackPanel : StackPanel
{
public TabScrollDirection TabScrollDirection
public TabScrollDirection ScrollDirection
{
get => (TabScrollDirection)GetValue(TabScrollDirectionProperty);
set => SetValue(TabScrollDirectionProperty, value);
get => (TabScrollDirection)GetValue(ScrollDirectionProperty);
set => SetValue(ScrollDirectionProperty, value);
}

public static readonly DependencyProperty TabScrollDirectionProperty =
DependencyProperty.Register(nameof(TabScrollDirection), typeof(TabScrollDirection),
public static readonly DependencyProperty ScrollDirectionProperty =
DependencyProperty.Register(nameof(ScrollDirection), typeof(TabScrollDirection),
typeof(PaddedBringIntoViewStackPanel), new PropertyMetadata(TabScrollDirection.Unknown));

public double TabScrollOffset
Expand All @@ -34,8 +34,8 @@ private void OnRequestBringIntoView(object sender, RoutedEventArgs e)
{
e.Handled = true;

// TODO: Consider making the "TabScrollDirection" 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 = TabScrollDirection switch {
// 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 => -TabScrollOffset,
TabScrollDirection.Forward => TabScrollOffset,
_ => 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<behaviorsInternal:TabControlHeaderScrollBehavior TabControl="{Binding RelativeSource={RelativeSource TemplatedParent}}" ScrollableContent="{Binding ElementName=ScrollableContent}" />
</b:Interaction.Behaviors>
<internal:PaddedBringIntoViewStackPanel x:Name="ScrollableContent"
TabScrollDirection="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(behaviorsInternal:TabControlHeaderScrollBehavior.TabScrollDirection)}"
ScrollDirection="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(behaviorsInternal:TabControlHeaderScrollBehavior.ScrollDirection)}"
TabScrollOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:TabAssist.TabScrollOffset)}">
<UniformGrid x:Name="CenteredHeaderPanel"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Expand Down