Skip to content

Commit 9bf5b77

Browse files
committed
A more md-standard implementation of blackout.
Some visual regression here that James may or may not be comfortable with in a minor release.
1 parent 9d4147b commit 9bf5b77

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Calendar.xaml

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<Setter Property="MinWidth" Value="5"/>
88
<Setter Property="MinHeight" Value="5"/>
99
<Setter Property="FontSize" Value="12"/>
10+
<Setter Property="Cursor" Value="Hand"/>
1011
<Setter Property="Background" Value="Transparent"/>
1112
<Setter Property="Margin" Value="2"/>
1213
<Setter Property="Width" Value="48" />
@@ -86,11 +87,7 @@
8687
<VisualTransition GeneratedDuration="0"/>
8788
</VisualStateGroup.Transitions>
8889
<VisualState x:Name="Active"/>
89-
<VisualState x:Name="Inactive">
90-
<Storyboard>
91-
<!--ColorAnimation Duration="0" To="#FF777777" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/-->
92-
</Storyboard>
93-
</VisualState>
90+
<VisualState x:Name="Inactive" />
9491
</VisualStateGroup>
9592
<VisualStateGroup x:Name="DayStates">
9693
<VisualStateGroup.Transitions>
@@ -113,39 +110,44 @@
113110
<VisualState x:Name="NormalDay"/>
114111
<VisualState x:Name="BlackoutDay">
115112
<Storyboard>
116-
<DoubleAnimation Duration="0" To=".2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Blackout"/>
113+
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightingBorder" />
114+
<DoubleAnimation Duration="0" To="0.38" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalText" />
117115
</Storyboard>
118116
</VisualState>
119117
</VisualStateGroup>
120118
</VisualStateManager.VisualStateGroups>
121119
<Ellipse x:Name="TodayBackground" Fill="{DynamicResource PrimaryHueLightBrush}" Opacity="0" />
122120
<Ellipse x:Name="SelectedBackground" Fill="{DynamicResource PrimaryHueMidBrush}" Opacity="0" />
123-
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
124-
<Ellipse x:Name="HighlightBackground" Fill="{DynamicResource PrimaryHueDarkBrush}" Opacity="0" />
125-
<ContentPresenter x:Name="NormalText"
126-
TextElement.Foreground="{TemplateBinding Foreground}"
121+
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" />
122+
<Border x:Name="HighlightingBorder" Opacity="1">
123+
<Ellipse x:Name="HighlightBackground" Fill="{DynamicResource PrimaryHueDarkBrush}" Opacity="0" />
124+
</Border>
125+
<ContentPresenter x:Name="NormalText"
126+
TextElement.Foreground="{TemplateBinding Foreground}"
127127
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
128-
Margin="5,1,5,1"
128+
Margin="5,1,5,1"
129129
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
130-
<Path x:Name="Blackout"
131-
Fill="#FF000000"
132-
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
133-
Margin="3"
134-
Opacity="0"
135-
RenderTransformOrigin="0.5,0.5"
136-
Stretch="Fill"
137-
Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" />
138-
<Ellipse x:Name="DayButtonFocusVisual" Stroke="{DynamicResource PrimaryHueDarkBrush}" Opacity="0" Visibility="Collapsed" StrokeThickness="1"/>
130+
<Ellipse x:Name="DayButtonFocusVisual" Stroke="{DynamicResource PrimaryHueDarkBrush}" Opacity="0" Visibility="Collapsed" StrokeThickness="1" />
139131
</Grid>
140132
</ControlTemplate>
141133
</Setter.Value>
142134
</Setter>
135+
<Style.Triggers>
136+
<Trigger Property="IsInactive" Value="True">
137+
<Setter Property="MinHeight" Value="0" />
138+
<Setter Property="MaxHeight" Value="0" />
139+
</Trigger>
140+
<Trigger Property="IsBlackedOut" Value="True">
141+
<Setter Property="Cursor" Value="No" />
142+
</Trigger>
143+
</Style.Triggers>
143144
</Style>
144145

145146
<Style x:Key="MaterialDesignCalendarDayButton" TargetType="{x:Type CalendarDayButton}">
146147
<Setter Property="MinWidth" Value="5"/>
147148
<Setter Property="MinHeight" Value="5"/>
148149
<Setter Property="FontSize" Value="12"/>
150+
<Setter Property="Cursor" Value="Hand" />
149151
<Setter Property="Margin" Value="2"/>
150152
<Setter Property="Width" Value="34" />
151153
<Setter Property="Height" Value="34" />
@@ -224,11 +226,7 @@
224226
<VisualTransition GeneratedDuration="0"/>
225227
</VisualStateGroup.Transitions>
226228
<VisualState x:Name="Active"/>
227-
<VisualState x:Name="Inactive">
228-
<Storyboard>
229-
<DoubleAnimation Duration="0" To="0.35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalText"/>
230-
</Storyboard>
231-
</VisualState>
229+
<VisualState x:Name="Inactive"/>
232230
</VisualStateGroup>
233231
<VisualStateGroup x:Name="DayStates">
234232
<VisualStateGroup.Transitions>
@@ -251,31 +249,39 @@
251249
<VisualState x:Name="NormalDay"/>
252250
<VisualState x:Name="BlackoutDay">
253251
<Storyboard>
254-
<DoubleAnimation Duration="0" To="0.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Blackout"/>
252+
<DoubleAnimation Duration="0"
253+
To="0"
254+
Storyboard.TargetProperty="Opacity"
255+
Storyboard.TargetName="HighlightingBorder"/>
256+
<DoubleAnimation Duration="0"
257+
To="0.38"
258+
Storyboard.TargetProperty="Opacity"
259+
Storyboard.TargetName="NormalText" />
255260
</Storyboard>
256261
</VisualState>
257262
</VisualStateGroup>
258263
</VisualStateManager.VisualStateGroups>
259264
<Ellipse x:Name="TodayBackground" Fill="{DynamicResource PrimaryHueLightBrush}" Opacity="0" />
260265
<Ellipse x:Name="SelectedBackground" Fill="{DynamicResource PrimaryHueMidBrush}" Opacity="0" />
261266
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
262-
<Ellipse x:Name="HighlightBackground" Fill="{DynamicResource PrimaryHueDarkBrush}" Opacity="0" />
263-
<ContentPresenter x:Name="NormalText" TextElement.Foreground="{TemplateBinding Foreground}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="5,1,5,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
264-
<Path x:Name="Blackout"
265-
Data="M 16 0 l -16 16"
266-
StrokeThickness="1.5"
267-
Stroke="#FF000000"
268-
HorizontalAlignment="Stretch"
269-
VerticalAlignment="Stretch"
270-
Margin="3"
271-
Opacity="0"
272-
RenderTransformOrigin="0.5,0.5"
273-
Stretch="Fill"/>
267+
<Border x:Name="HighlightingBorder" Opacity="1">
268+
<Ellipse x:Name="HighlightBackground" Fill="{DynamicResource PrimaryHueDarkBrush}" Opacity="0"/>
269+
</Border>
270+
<ContentPresenter x:Name="NormalText" TextElement.Foreground="{TemplateBinding Foreground}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="5,1,5,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
274271
<Ellipse x:Name="DayButtonFocusVisual" Stroke="{DynamicResource PrimaryHueDarkBrush}" Opacity="0" Visibility="Collapsed" StrokeThickness="1"/>
275272
</Grid>
276273
</ControlTemplate>
277274
</Setter.Value>
278275
</Setter>
276+
<Style.Triggers>
277+
<Trigger Property="IsInactive" Value="True">
278+
<Setter Property="MinHeight" Value="0" />
279+
<Setter Property="MaxHeight" Value="0" />
280+
</Trigger>
281+
<Trigger Property="IsBlackedOut" Value="True">
282+
<Setter Property="Cursor" Value="No" />
283+
</Trigger>
284+
</Style.Triggers>
279285
</Style>
280286

281287
<Style x:Key="MaterialDesignCalendarItemPortrait" TargetType="{x:Type CalendarItem}">
@@ -433,7 +439,7 @@
433439
<TranslateTransform X="0"/>
434440
</Border.RenderTransform>
435441
</Border>
436-
<Grid x:Name="PART_MonthView" RenderTransformOrigin="0, 0.5">
442+
<Grid x:Name="PART_MonthView" RenderTransformOrigin="0, 0.5" MinHeight="254">
437443
<Grid.RenderTransform>
438444
<TranslateTransform X="0" />
439445
</Grid.RenderTransform>

0 commit comments

Comments
 (0)