Skip to content

Commit 15bbe66

Browse files
committed
Inherit FontFamily and FontSize for CalendarDayButton and CalendarButton from Calendar.
1 parent 3d5ff98 commit 15bbe66

File tree

4 files changed

+45
-23
lines changed

4 files changed

+45
-23
lines changed

docs/release-notes/1.6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Add ContentStringFormat / ContentTemplateSelector to ContentPresenter of `RadioButton`. [#2954](https://github.com/MahApps/MahApps.Metro/pull/2954) [@pmccowat](https://github.com/pmccowat)
77
- Add ContentStringFormat / ContentTemplateSelector to ContentPresenter of `CheckBox`.
88
- DisplayFormat for time and date in DateTimePicker and TimePicker [#2930](https://github.com/MahApps/MahApps.Metro/pull/2930) @[xxMUROxx](https://github.com/xxMUROxx)
9+
- Inherit FontFamily and FontSize for `CalendarDayButton` and `CalendarButton` from `Calendar`.
910

1011
## Closed Issues
1112

src/MahApps.Metro/MahApps.Metro/Styles/Controls.Calendar.xaml

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
22

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

147-
<Style x:Key="MetroCalendarItemStyle" TargetType="{x:Type CalendarItem}">
147+
<!-- obsolete -->
148+
<Style x:Key="MetroCalendarDayButtonStyle"
149+
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendarDayButtonStyle}"
150+
TargetType="{x:Type CalendarDayButton}" />
151+
152+
<Style x:Key="MahApps.Metro.Styles.MetroCalendarItemStyle" TargetType="{x:Type CalendarItem}">
148153
<Setter Property="Margin" Value="0 3" />
149154
<Setter Property="Padding" Value="2" />
150155
<Setter Property="SnapsToDevicePixels" Value="True" />
@@ -157,8 +162,6 @@
157162
<TextBlock Margin="0 6 0 6"
158163
HorizontalAlignment="Center"
159164
VerticalAlignment="Center"
160-
FontFamily="{DynamicResource ContentFontFamily}"
161-
FontSize="{DynamicResource ContentFontSize}"
162165
FontWeight="Bold"
163166
Foreground="{DynamicResource BlackBrush}"
164167
Opacity="0.8"
@@ -184,7 +187,7 @@
184187
<Path x:Name="path"
185188
Width="6"
186189
Height="10"
187-
Margin="14,-6,0,0"
190+
Margin="14 -6 0 0"
188191
HorizontalAlignment="Left"
189192
VerticalAlignment="Center"
190193
Data="M288.75,232.25 L288.75,240.625 L283,236.625 z"
@@ -222,7 +225,7 @@
222225
<Path x:Name="path"
223226
Width="6"
224227
Height="10"
225-
Margin="0,-6,14,0"
228+
Margin="0 -6 14 0"
226229
HorizontalAlignment="Right"
227230
VerticalAlignment="Center"
228231
Data="M282.875,231.875 L282.875,240.375 L288.625,236 z"
@@ -255,14 +258,12 @@
255258
<ControlTemplate x:Key="HeaderButtonTemplate" TargetType="{x:Type Button}">
256259
<Grid Cursor="Hand">
257260
<ContentPresenter x:Name="buttonContent"
258-
Margin="1,4,1,9"
261+
Margin="1 4 1 9"
259262
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
260263
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
261264
Content="{TemplateBinding Content}"
262265
ContentTemplate="{TemplateBinding ContentTemplate}"
263-
Opacity="0.7"
264-
TextElement.FontFamily="{DynamicResource ContentFontFamily}"
265-
TextElement.Foreground="{DynamicResource AccentSelectedColorBrush}" />
266+
Opacity="0.7" />
266267
<VisualStateManager.VisualStateGroups>
267268
<VisualStateGroup x:Name="CommonStates">
268269
<VisualState x:Name="Normal" />
@@ -314,8 +315,6 @@
314315
HorizontalAlignment="Center"
315316
VerticalAlignment="Center"
316317
Focusable="False"
317-
FontFamily="{DynamicResource ContentFontFamily}"
318-
FontSize="{DynamicResource ContentFontSize}"
319318
FontWeight="Bold"
320319
Style="{StaticResource HeaderCalendarButtonStyle}" />
321320
<Button x:Name="PART_PreviousButton"
@@ -417,11 +416,16 @@
417416
</Setter>
418417
</Style>
419418

419+
<!-- obsolete -->
420+
<Style x:Key="MetroCalendarItemStyle"
421+
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendarItemStyle}"
422+
TargetType="{x:Type CalendarItem}" />
423+
420424
<!-- Style for Month and Year buttons -->
421-
<Style x:Key="MetroCalendarButtonStyle" TargetType="{x:Type CalendarButton}">
425+
<Style x:Key="MahApps.Metro.Styles.MetroCalendarButtonStyle" TargetType="{x:Type CalendarButton}">
422426
<Setter Property="Background" Value="{DynamicResource AccentColorBrush4}" />
423-
<Setter Property="FontFamily" Value="{DynamicResource ContentFontFamily}" />
424-
<Setter Property="FontSize" Value="{DynamicResource ContentFontSize}" />
427+
<Setter Property="FontFamily" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}, Path=FontFamily, Mode=OneWay}" />
428+
<Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}, Path=FontSize, Mode=OneWay}" />
425429
<Setter Property="HorizontalContentAlignment" Value="Center" />
426430
<Setter Property="MinHeight" Value="42" />
427431
<Setter Property="MinWidth" Value="40" />
@@ -541,13 +545,18 @@
541545
<Setter Property="VerticalContentAlignment" Value="Center" />
542546
</Style>
543547

544-
<Style x:Key="MetroCalendar" TargetType="{x:Type Calendar}">
548+
<!-- obsolete -->
549+
<Style x:Key="MetroCalendarButtonStyle"
550+
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendarButtonStyle}"
551+
TargetType="{x:Type CalendarButton}" />
552+
553+
<Style x:Key="MahApps.Metro.Styles.BaseMetroCalendar" TargetType="{x:Type Calendar}">
545554
<Setter Property="Background" Value="{DynamicResource WhiteBrush}" />
546555
<Setter Property="BorderBrush" Value="{DynamicResource BlackBrush}" />
547556
<Setter Property="BorderThickness" Value="1" />
548-
<Setter Property="CalendarButtonStyle" Value="{DynamicResource MetroCalendarButtonStyle}" />
549-
<Setter Property="CalendarDayButtonStyle" Value="{DynamicResource MetroCalendarDayButtonStyle}" />
550-
<Setter Property="CalendarItemStyle" Value="{DynamicResource MetroCalendarItemStyle}" />
557+
<Setter Property="CalendarButtonStyle" Value="{DynamicResource MahApps.Metro.Styles.MetroCalendarButtonStyle}" />
558+
<Setter Property="CalendarDayButtonStyle" Value="{DynamicResource MahApps.Metro.Styles.MetroCalendarDayButtonStyle}" />
559+
<Setter Property="CalendarItemStyle" Value="{DynamicResource MahApps.Metro.Styles.MetroCalendarItemStyle}" />
551560
<Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
552561
<Setter Property="HorizontalContentAlignment" Value="Left" />
553562
<Setter Property="SnapsToDevicePixels" Value="True" />
@@ -568,4 +577,16 @@
568577
</Setter.Value>
569578
</Setter>
570579
</Style>
580+
581+
<Style x:Key="MahApps.Metro.Styles.MetroCalendar"
582+
BasedOn="{StaticResource MahApps.Metro.Styles.BaseMetroCalendar}"
583+
TargetType="{x:Type Calendar}">
584+
<Setter Property="FontFamily" Value="{DynamicResource ContentFontFamily}" />
585+
<Setter Property="FontSize" Value="{DynamicResource ContentFontSize}" />
586+
</Style>
587+
588+
<!-- obsolete -->
589+
<Style x:Key="MetroCalendar"
590+
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendar}"
591+
TargetType="{x:Type Calendar}" />
571592
</ResourceDictionary>

src/MahApps.Metro/MahApps.Metro/Styles/Controls.DatePicker.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}" />
1919
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
2020
<Setter Property="BorderThickness" Value="1" />
21-
<Setter Property="CalendarStyle" Value="{DynamicResource MetroCalendar}" />
21+
<Setter Property="CalendarStyle" Value="{DynamicResource MahApps.Metro.Styles.BaseMetroCalendar}" />
2222
<Setter Property="Controls:ControlsHelper.FocusBorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
2323
<Setter Property="Controls:ControlsHelper.MouseOverBorderBrush" Value="{DynamicResource TextBoxMouseOverBorderBrush}" />
2424
<Setter Property="Controls:TextBoxHelper.ButtonWidth" Value="22" />

src/MahApps.Metro/MahApps.Metro/Styles/Controls.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<Style BasedOn="{StaticResource MetroTreeViewItem}" TargetType="TreeViewItem" />
108108
<Style BasedOn="{StaticResource MetroDatePicker}" TargetType="DatePicker" />
109109
<Style BasedOn="{StaticResource MetroDatePickerTextBox}" TargetType="DatePickerTextBox" />
110-
<Style BasedOn="{StaticResource MetroCalendar}" TargetType="Calendar" />
110+
<Style BasedOn="{StaticResource MahApps.Metro.Styles.MetroCalendar}" TargetType="Calendar" />
111111
<Style BasedOn="{StaticResource MetroDataGrid}" TargetType="DataGrid" />
112112
<Style BasedOn="{StaticResource MetroStatusBar}" TargetType="StatusBar" />
113113
<Style BasedOn="{StaticResource MetroStatusBarItem}" TargetType="StatusBarItem" />

0 commit comments

Comments
 (0)