Skip to content

Commit ea9617c

Browse files
authored
Merge pull request #132 from Laritello/new-tab-item-assist-properties
Add new properties to TabControlAssist
2 parents 1163ccd + bb6b549 commit ea9617c

File tree

2 files changed

+95
-2
lines changed

2 files changed

+95
-2
lines changed

MaterialDesignExtensions/Controls/TabControlAssist.cs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,96 @@ public static void SetTabHeaderForeground(DependencyObject element, Brush value)
192192
{
193193
element.SetValue(TabHeaderForegroundProperty, value);
194194
}
195+
196+
/// <summary>
197+
/// The current font size of the tab item header. Intended to be read-only.
198+
/// </summary>
199+
public static readonly DependencyProperty TabHeaderFontSizeProperty = DependencyProperty.RegisterAttached(
200+
"TabHeaderFontSize",
201+
typeof(double),
202+
typeof(TabControlAssist),
203+
new FrameworkPropertyMetadata(14.0, FrameworkPropertyMetadataOptions.Inherits, null)
204+
);
205+
206+
/// <summary>
207+
/// Gets the current font size of the tab item header.
208+
/// </summary>
209+
/// <param name="element"></param>
210+
/// <returns></returns>
211+
public static double GetTabHeaderFontSize(DependencyObject element)
212+
{
213+
return (double)element.GetValue(TabHeaderFontSizeProperty);
214+
}
215+
216+
/// <summary>
217+
/// Sets the current font size of the tab item header.
218+
/// </summary>
219+
/// <param name="element"></param>
220+
/// <param name="value"></param>
221+
public static void SetTabHeaderFontSize(DependencyObject element, double value)
222+
{
223+
element.SetValue(TabHeaderFontSizeProperty, value);
224+
}
225+
226+
/// <summary>
227+
/// The current font weight of the tab item header. Intended to be read-only.
228+
/// </summary>
229+
public static readonly DependencyProperty TabHeaderFontWeightProperty = DependencyProperty.RegisterAttached(
230+
"TabHeaderFontWeight",
231+
typeof(FontWeight),
232+
typeof(TabControlAssist),
233+
new FrameworkPropertyMetadata(FontWeights.Medium, FrameworkPropertyMetadataOptions.Inherits, null)
234+
);
235+
236+
/// <summary>
237+
/// Gets the current font weight of the tab item header.
238+
/// </summary>
239+
/// <param name="element"></param>
240+
/// <returns></returns>
241+
public static FontWeight GetTabHeaderFontWeight(DependencyObject element)
242+
{
243+
return (FontWeight)element.GetValue(TabHeaderFontWeightProperty);
244+
}
245+
246+
/// <summary>
247+
/// Sets the current font weight of the tab item header.
248+
/// </summary>
249+
/// <param name="element"></param>
250+
/// <param name="value"></param>
251+
public static void SetTabHeaderFontWeight(DependencyObject element, FontWeight value)
252+
{
253+
element.SetValue(TabHeaderFontWeightProperty, value);
254+
}
255+
256+
257+
/// <summary>
258+
/// The current margin of the tab item header's content. Intended to be read-only.
259+
/// </summary>
260+
public static readonly DependencyProperty TabHeaderMarginProperty = DependencyProperty.RegisterAttached(
261+
"TabHeaderMargin",
262+
typeof(Thickness),
263+
typeof(TabControlAssist),
264+
new FrameworkPropertyMetadata(new Thickness(24,12,24,12), FrameworkPropertyMetadataOptions.Inherits, null)
265+
);
266+
267+
/// <summary>
268+
/// Gets the current margin of the tab item header's content.
269+
/// </summary>
270+
/// <param name="element"></param>
271+
/// <returns></returns>
272+
public static Thickness GetTabHeaderMargin(DependencyObject element)
273+
{
274+
return (Thickness)element.GetValue(TabHeaderMarginProperty);
275+
}
276+
277+
/// <summary>
278+
/// Sets the current margin of the tab item header's content.
279+
/// </summary>
280+
/// <param name="element"></param>
281+
/// <param name="value"></param>
282+
public static void SetTabHeaderMargin(DependencyObject element, Thickness value)
283+
{
284+
element.SetValue(TabHeaderMarginProperty, value);
285+
}
195286
}
196287
}

MaterialDesignExtensions/Themes/TabControlTemplates.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@
7575
</Border.RenderTransform>
7676
</Border>
7777
<ContentPresenter x:Name="headerContent" ContentSource="Header" RecognizesAccessKey="True"
78-
Margin="24,12,24,12" HorizontalAlignment="Center" VerticalAlignment="Center"
79-
TextBlock.FontSize="14" TextBlock.FontWeight="Medium"
78+
HorizontalAlignment="Center" VerticalAlignment="Center"
79+
Margin="{Binding Path=(controls:TabControlAssist.TabHeaderMargin), RelativeSource={RelativeSource TemplatedParent}}"
80+
TextBlock.FontSize="{Binding Path=(controls:TabControlAssist.TabHeaderFontSize), RelativeSource={RelativeSource TemplatedParent}}"
81+
TextBlock.FontWeight="{Binding Path=(controls:TabControlAssist.TabHeaderFontWeight), RelativeSource={RelativeSource TemplatedParent}}"
8082
TextBlock.Foreground="{Binding Path=(controls:TabControlAssist.TabHeaderForeground), RelativeSource={RelativeSource TemplatedParent}}">
8183
<ContentPresenter.Style>
8284
<Style TargetType="ContentPresenter">

0 commit comments

Comments
 (0)