Skip to content

Commit 737223f

Browse files
Rename TabScrollOffset
1 parent f001a07 commit 737223f

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/MaterialDesignThemes.Wpf/Behaviors/Internal/TabControlHeaderScrollBehavior.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics;
1+
using System.Diagnostics;
22
using System.Windows.Media.Animation;
33
using Microsoft.Xaml.Behaviors;
44

@@ -70,7 +70,7 @@ private static void OnScrollableContentChanged(DependencyObject d, DependencyPro
7070

7171
private void OnTabChanged(object sender, SelectionChangedEventArgs e)
7272
{
73-
TabControl tabControl = (TabControl)sender;
73+
var tabControl = (TabControl)sender;
7474

7575
if (e.AddedItems.Count > 0)
7676
{
@@ -99,7 +99,7 @@ private void AddPaddingToScrollableContentIfWiderThanViewPort()
9999

100100
if (ScrollableContent.ActualWidth > TabControl.ActualWidth)
101101
{
102-
double offset = TabAssist.GetTabScrollOffset(TabControl);
102+
double offset = TabAssist.GetHeaderPadding(TabControl);
103103
ScrollableContent.Margin = new(offset, 0, offset, 0);
104104
}
105105
else

src/MaterialDesignThemes.Wpf/Internal/PaddedBringIntoViewStackPanel.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public TabScrollDirection ScrollDirection
1515
DependencyProperty.Register(nameof(ScrollDirection), typeof(TabScrollDirection),
1616
typeof(PaddedBringIntoViewStackPanel), new PropertyMetadata(TabScrollDirection.Unknown));
1717

18-
public double TabScrollOffset
18+
public double HeaderPadding
1919
{
20-
get => (double)GetValue(TabScrollOffsetProperty);
21-
set => SetValue(TabScrollOffsetProperty, value);
20+
get => (double)GetValue(HeaderPaddingProperty);
21+
set => SetValue(HeaderPaddingProperty, value);
2222
}
2323

24-
public static readonly DependencyProperty TabScrollOffsetProperty =
25-
DependencyProperty.Register(nameof(TabScrollOffset),
24+
public static readonly DependencyProperty HeaderPaddingProperty =
25+
DependencyProperty.Register(nameof(HeaderPadding),
2626
typeof(double), typeof(PaddedBringIntoViewStackPanel), new PropertyMetadata(0d));
2727

2828
public PaddedBringIntoViewStackPanel()
@@ -36,8 +36,8 @@ private void OnRequestBringIntoView(object sender, RoutedEventArgs e)
3636

3737
// 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.
3838
double offset = ScrollDirection switch {
39-
TabScrollDirection.Backward => -TabScrollOffset,
40-
TabScrollDirection.Forward => TabScrollOffset,
39+
TabScrollDirection.Backward => -HeaderPadding,
40+
TabScrollDirection.Forward => HeaderPadding,
4141
_ => 0
4242
};
4343
var point = child.TranslatePoint(new Point(), this);

src/MaterialDesignThemes.Wpf/TabAssist.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ public static void SetHeaderBehavior(DependencyObject obj, TabControlHeaderBehav
7070
DependencyProperty.RegisterAttached("HeaderBehavior", typeof(TabControlHeaderBehavior), typeof(TabAssist),
7171
new PropertyMetadata(TabControlHeaderBehavior.Scrolling));
7272

73-
public static double GetTabScrollOffset(DependencyObject obj)
74-
=> (double)obj.GetValue(TabScrollOffsetProperty);
73+
public static double GetHeaderPadding(DependencyObject obj)
74+
=> (double)obj.GetValue(HeaderPaddingProperty);
7575

76-
public static void SetTabScrollOffset(DependencyObject obj, double value)
77-
=> obj.SetValue(TabScrollOffsetProperty, value);
76+
public static void SetHeaderPadding(DependencyObject obj, double value)
77+
=> obj.SetValue(HeaderPaddingProperty, value);
7878

79-
public static readonly DependencyProperty TabScrollOffsetProperty =
80-
DependencyProperty.RegisterAttached("TabScrollOffset", typeof(double),
79+
public static readonly DependencyProperty HeaderPaddingProperty =
80+
DependencyProperty.RegisterAttached("HeaderPadding", typeof(double),
8181
typeof(TabAssist), new PropertyMetadata(0d));
8282

8383
public static TimeSpan GetTabScrollDuration(DependencyObject obj)

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</b:Interaction.Behaviors>
4545
<internal:PaddedBringIntoViewStackPanel x:Name="ScrollableContent"
4646
ScrollDirection="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(behaviorsInternal:TabControlHeaderScrollBehavior.ScrollDirection)}"
47-
TabScrollOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:TabAssist.TabScrollOffset)}">
47+
HeaderPadding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:TabAssist.HeaderPadding)}">
4848
<UniformGrid x:Name="CenteredHeaderPanel"
4949
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
5050
Margin="{Binding Path=(wpf:TabAssist.HeaderPanelMargin), RelativeSource={RelativeSource TemplatedParent}}"
@@ -236,7 +236,7 @@
236236
<Setter Property="wpf:RippleAssist.Feedback" Value="{DynamicResource MaterialDesign.Brush.Button.Ripple}" />
237237
<Setter Property="wpf:TabAssist.HasUniformTabWidth" Value="False" />
238238
<!-- MD spec says 52 DP, but that seems a little excessive in practice -->
239-
<Setter Property="wpf:TabAssist.TabScrollOffset" Value="40" />
239+
<Setter Property="wpf:TabAssist.HeaderPadding" Value="40" />
240240
<Setter Property="wpf:TabAssist.TabScrollDuration" Value="0:0:0.250" />
241241

242242
<Style.Triggers>

0 commit comments

Comments
 (0)