Skip to content

Commit

Permalink
Inherit FontFamily and FontSize for CalendarDayButton and `Calendar…
Browse files Browse the repository at this point in the history
…Button` from `Calendar`.
  • Loading branch information
punker76 committed May 17, 2017
1 parent 3d5ff98 commit 15bbe66
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 23 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/1.6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Add ContentStringFormat / ContentTemplateSelector to ContentPresenter of `RadioButton`. [#2954](https://github.com/MahApps/MahApps.Metro/pull/2954) [@pmccowat](https://github.com/pmccowat)
- Add ContentStringFormat / ContentTemplateSelector to ContentPresenter of `CheckBox`.
- DisplayFormat for time and date in DateTimePicker and TimePicker [#2930](https://github.com/MahApps/MahApps.Metro/pull/2930) @[xxMUROxx](https://github.com/xxMUROxx)
- Inherit FontFamily and FontSize for `CalendarDayButton` and `CalendarButton` from `Calendar`.

## Closed Issues

Expand Down
63 changes: 42 additions & 21 deletions src/MahApps.Metro/MahApps.Metro/Styles/Controls.Calendar.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="MetroCalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
<Setter Property="FontFamily" Value="{DynamicResource ContentFontFamily}" />
<Setter Property="FontSize" Value="{DynamicResource ContentFontSize}" />
<Style x:Key="MahApps.Metro.Styles.MetroCalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
<Setter Property="FontFamily" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}, Path=FontFamily, Mode=OneWay}" />
<Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}, Path=FontSize, Mode=OneWay}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="MinHeight" Value="5" />
<Setter Property="MinWidth" Value="5" />
Expand Down Expand Up @@ -144,7 +144,12 @@
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>

<Style x:Key="MetroCalendarItemStyle" TargetType="{x:Type CalendarItem}">
<!-- obsolete -->
<Style x:Key="MetroCalendarDayButtonStyle"
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendarDayButtonStyle}"
TargetType="{x:Type CalendarDayButton}" />

<Style x:Key="MahApps.Metro.Styles.MetroCalendarItemStyle" TargetType="{x:Type CalendarItem}">
<Setter Property="Margin" Value="0 3" />
<Setter Property="Padding" Value="2" />
<Setter Property="SnapsToDevicePixels" Value="True" />
Expand All @@ -157,8 +162,6 @@
<TextBlock Margin="0 6 0 6"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{DynamicResource ContentFontFamily}"
FontSize="{DynamicResource ContentFontSize}"
FontWeight="Bold"
Foreground="{DynamicResource BlackBrush}"
Opacity="0.8"
Expand All @@ -184,7 +187,7 @@
<Path x:Name="path"
Width="6"
Height="10"
Margin="14,-6,0,0"
Margin="14 -6 0 0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Data="M288.75,232.25 L288.75,240.625 L283,236.625 z"
Expand Down Expand Up @@ -222,7 +225,7 @@
<Path x:Name="path"
Width="6"
Height="10"
Margin="0,-6,14,0"
Margin="0 -6 14 0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Data="M282.875,231.875 L282.875,240.375 L288.625,236 z"
Expand Down Expand Up @@ -255,14 +258,12 @@
<ControlTemplate x:Key="HeaderButtonTemplate" TargetType="{x:Type Button}">
<Grid Cursor="Hand">
<ContentPresenter x:Name="buttonContent"
Margin="1,4,1,9"
Margin="1 4 1 9"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Opacity="0.7"
TextElement.FontFamily="{DynamicResource ContentFontFamily}"
TextElement.Foreground="{DynamicResource AccentSelectedColorBrush}" />
Opacity="0.7" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
Expand Down Expand Up @@ -314,8 +315,6 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
FontFamily="{DynamicResource ContentFontFamily}"
FontSize="{DynamicResource ContentFontSize}"
FontWeight="Bold"
Style="{StaticResource HeaderCalendarButtonStyle}" />
<Button x:Name="PART_PreviousButton"
Expand Down Expand Up @@ -417,11 +416,16 @@
</Setter>
</Style>

<!-- obsolete -->
<Style x:Key="MetroCalendarItemStyle"
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendarItemStyle}"
TargetType="{x:Type CalendarItem}" />

<!-- Style for Month and Year buttons -->
<Style x:Key="MetroCalendarButtonStyle" TargetType="{x:Type CalendarButton}">
<Style x:Key="MahApps.Metro.Styles.MetroCalendarButtonStyle" TargetType="{x:Type CalendarButton}">
<Setter Property="Background" Value="{DynamicResource AccentColorBrush4}" />
<Setter Property="FontFamily" Value="{DynamicResource ContentFontFamily}" />
<Setter Property="FontSize" Value="{DynamicResource ContentFontSize}" />
<Setter Property="FontFamily" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}, Path=FontFamily, Mode=OneWay}" />
<Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}, Path=FontSize, Mode=OneWay}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="MinHeight" Value="42" />
<Setter Property="MinWidth" Value="40" />
Expand Down Expand Up @@ -541,13 +545,18 @@
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>

<Style x:Key="MetroCalendar" TargetType="{x:Type Calendar}">
<!-- obsolete -->
<Style x:Key="MetroCalendarButtonStyle"
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendarButtonStyle}"
TargetType="{x:Type CalendarButton}" />

<Style x:Key="MahApps.Metro.Styles.BaseMetroCalendar" TargetType="{x:Type Calendar}">
<Setter Property="Background" Value="{DynamicResource WhiteBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BlackBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CalendarButtonStyle" Value="{DynamicResource MetroCalendarButtonStyle}" />
<Setter Property="CalendarDayButtonStyle" Value="{DynamicResource MetroCalendarDayButtonStyle}" />
<Setter Property="CalendarItemStyle" Value="{DynamicResource MetroCalendarItemStyle}" />
<Setter Property="CalendarButtonStyle" Value="{DynamicResource MahApps.Metro.Styles.MetroCalendarButtonStyle}" />
<Setter Property="CalendarDayButtonStyle" Value="{DynamicResource MahApps.Metro.Styles.MetroCalendarDayButtonStyle}" />
<Setter Property="CalendarItemStyle" Value="{DynamicResource MahApps.Metro.Styles.MetroCalendarItemStyle}" />
<Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="SnapsToDevicePixels" Value="True" />
Expand All @@ -568,4 +577,16 @@
</Setter.Value>
</Setter>
</Style>

<Style x:Key="MahApps.Metro.Styles.MetroCalendar"
BasedOn="{StaticResource MahApps.Metro.Styles.BaseMetroCalendar}"
TargetType="{x:Type Calendar}">
<Setter Property="FontFamily" Value="{DynamicResource ContentFontFamily}" />
<Setter Property="FontSize" Value="{DynamicResource ContentFontSize}" />
</Style>

<!-- obsolete -->
<Style x:Key="MetroCalendar"
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendar}"
TargetType="{x:Type Calendar}" />
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CalendarStyle" Value="{DynamicResource MetroCalendar}" />
<Setter Property="CalendarStyle" Value="{DynamicResource MahApps.Metro.Styles.BaseMetroCalendar}" />
<Setter Property="Controls:ControlsHelper.FocusBorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
<Setter Property="Controls:ControlsHelper.MouseOverBorderBrush" Value="{DynamicResource TextBoxMouseOverBorderBrush}" />
<Setter Property="Controls:TextBoxHelper.ButtonWidth" Value="22" />
Expand Down
2 changes: 1 addition & 1 deletion src/MahApps.Metro/MahApps.Metro/Styles/Controls.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<Style BasedOn="{StaticResource MetroTreeViewItem}" TargetType="TreeViewItem" />
<Style BasedOn="{StaticResource MetroDatePicker}" TargetType="DatePicker" />
<Style BasedOn="{StaticResource MetroDatePickerTextBox}" TargetType="DatePickerTextBox" />
<Style BasedOn="{StaticResource MetroCalendar}" TargetType="Calendar" />
<Style BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendar}" TargetType="Calendar" />
<Style BasedOn="{StaticResource MetroDataGrid}" TargetType="DataGrid" />
<Style BasedOn="{StaticResource MetroStatusBar}" TargetType="StatusBar" />
<Style BasedOn="{StaticResource MetroStatusBarItem}" TargetType="StatusBarItem" />
Expand Down

0 comments on commit 15bbe66

Please sign in to comment.