Skip to content

Commit

Permalink
Add font setters to TabControl styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed May 5, 2020
1 parent 61dc8eb commit 58d1fd7
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 20 deletions.
2 changes: 2 additions & 0 deletions ModernWpf/Styles/Pivot.xaml
Expand Up @@ -102,6 +102,8 @@
<Style x:Key="TabControlPivotStyle" TargetType="TabControl">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Background" Value="{DynamicResource PivotBackground}" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="ItemContainerStyle" Value="{StaticResource TabItemPivotStyle}" />
<Setter Property="Template">
<Setter.Value>
Expand Down
2 changes: 2 additions & 0 deletions ModernWpf/Styles/TabControl.xaml
Expand Up @@ -170,6 +170,8 @@
<Style x:Key="DefaultTabControlStyle" TargetType="TabControl">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Background" Value="{DynamicResource TabViewBackground}" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabControl">
Expand Down
35 changes: 15 additions & 20 deletions test/ModernWpfTestApp/PivotPage.xaml
Expand Up @@ -10,25 +10,20 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid
Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}"
Margin="12">
<TabControl
x:Name="rootPivot"
Style="{StaticResource TabControlPivotStyle}"
controls:PivotHelper.Title="PIVOT TITLE">
<controls:PivotHelper.RightHeader>
<TextBlock Text="This is the right header" />
</controls:PivotHelper.RightHeader>
<TabItem Header="Pivot Item 1">
<TextBlock Text="Content of pivot item 1." />
</TabItem>
<TabItem Header="Pivot Item 2">
<TextBlock Text="Content of pivot item 2." />
</TabItem>
<TabItem Header="Pivot Item 3">
<TextBlock Text="Content of pivot item 3." />
</TabItem>
</TabControl>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="12">
<Pivot x:Name="rootPivot" Title="PIVOT TITLE">
<Pivot.RightHeader>
<TextBlock Text="This is the right header"/>
</Pivot.RightHeader>
<PivotItem Header="Pivot Item 1">
<TextBlock Text="Content of pivot item 1."/>
</PivotItem>
<PivotItem Header="Pivot Item 2">
<TextBlock Text="Content of pivot item 2."/>
</PivotItem>
<PivotItem Header="Pivot Item 3">
<TextBlock Text="Content of pivot item 3."/>
</PivotItem>
</Pivot>
</Grid>
</local:TestPage>
46 changes: 46 additions & 0 deletions test/TestAppUtils/Controls/Pivot.cs
@@ -0,0 +1,46 @@
using ModernWpf.Controls.Primitives;

namespace System.Windows.Controls
{
public class Pivot : TabControl
{
#region Title

public static readonly DependencyProperty TitleProperty = PivotHelper.TitleProperty.AddOwner(typeof(Pivot));

public object Title
{
get => GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}

#endregion

#region RightHeader

public static readonly DependencyProperty RightHeaderProperty = PivotHelper.RightHeaderProperty.AddOwner(typeof(Pivot));

public object RightHeader
{
get => GetValue(RightHeaderProperty);
set => SetValue(RightHeaderProperty, value);
}

#endregion

protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
this.InitializeStyle("TabControlPivotStyle");
}
}

public class PivotItem : TabItem
{
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
this.InitializeStyle("TabItemPivotStyle");
}
}
}

0 comments on commit 58d1fd7

Please sign in to comment.