Skip to content

Commit 2ab21cd

Browse files
committed
MUI calendar
1 parent dc164a0 commit 2ab21cd

File tree

1 file changed

+265
-0
lines changed

1 file changed

+265
-0
lines changed

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

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,4 +567,269 @@
567567
<Setter Property="FontSize" Value="{DynamicResource MahApps.Sizes.Font.Content}" />
568568
</Style>
569569

570+
<!-- MUI -->
571+
572+
<Style x:Key="MahApps.Styles.Calendar.Mui" TargetType="Calendar">
573+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ItemText.Mui}" />
574+
<Setter Property="Background" Value="Transparent" />
575+
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.ItemBorder.Mui}" />
576+
<Setter Property="BorderThickness" Value="1" />
577+
<Setter Property="CalendarButtonStyle" Value="{DynamicResource MahApps.Styles.CalendarButton.Mui}" />
578+
<Setter Property="CalendarDayButtonStyle" Value="{DynamicResource MahApps.Styles.CalendarDayButton.Mui}" />
579+
<Setter Property="CalendarItemStyle" Value="{DynamicResource MahApps.Styles.CalendarItem.Mui}" />
580+
581+
<Setter Property="Template">
582+
<Setter.Value>
583+
<ControlTemplate TargetType="Calendar">
584+
<StackPanel Name="PART_Root" HorizontalAlignment="Center">
585+
<CalendarItem
586+
Name="PART_CalendarItem"
587+
Style="{TemplateBinding CalendarItemStyle}"
588+
Background="{TemplateBinding Background}"
589+
BorderBrush="{TemplateBinding BorderBrush}"
590+
BorderThickness="{TemplateBinding BorderThickness}"
591+
/>
592+
</StackPanel>
593+
</ControlTemplate>
594+
</Setter.Value>
595+
</Setter>
596+
</Style>
597+
598+
<Style x:Key="MahApps.Styles.CalendarItem.Mui" TargetType="CalendarItem">
599+
<Setter Property="Template">
600+
<Setter.Value>
601+
<ControlTemplate TargetType="CalendarItem">
602+
<ControlTemplate.Resources>
603+
<DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
604+
<TextBlock x:Name="Text" FontWeight="Bold"
605+
FontSize="{DynamicResource DefaultFontSize}"
606+
Foreground="{DynamicResource MahApps.Brushes.ItemText.Mui}"
607+
HorizontalAlignment="Center"
608+
Text="{Binding}"
609+
Margin="0,6,0,6"
610+
VerticalAlignment="Center"/>
611+
</DataTemplate>
612+
</ControlTemplate.Resources>
613+
<Grid Name="PART_Root" >
614+
<Border
615+
BorderBrush="{TemplateBinding BorderBrush}"
616+
BorderThickness="{TemplateBinding BorderThickness}"
617+
Background="{TemplateBinding Background}">
618+
<Grid>
619+
<Grid.RowDefinitions>
620+
<RowDefinition Height="Auto"/>
621+
<RowDefinition Height="*"/>
622+
</Grid.RowDefinitions>
623+
<Grid.ColumnDefinitions>
624+
<ColumnDefinition Width="Auto"/>
625+
<ColumnDefinition Width="*" MinWidth="132"/>
626+
<ColumnDefinition Width="Auto"/>
627+
</Grid.ColumnDefinitions>
628+
629+
<Button x:Name="PART_PreviousButton"
630+
Grid.Row="0" Grid.Column="0"
631+
Margin="-1,-1,0,0"
632+
Padding="10,4,10,3"
633+
Focusable="False">
634+
<Path Height="10" Width="6" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Fill"
635+
Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Button}}"
636+
Data="F1 M 0,0 1,1 1,-1 Z" />
637+
</Button>
638+
639+
<Button x:Name="PART_NextButton"
640+
Grid.Row="0" Grid.Column="2"
641+
Margin="0,-1,-1,0"
642+
Padding="10,4,10,3"
643+
Focusable="False">
644+
<Path Height="10" Width="6" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Fill"
645+
Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Button}}"
646+
Data="F1 M 0,1 1,0 0,-1 Z" />
647+
</Button>
648+
649+
<Button x:Name="PART_HeaderButton"
650+
Grid.Row="0" Grid.Column="1"
651+
Margin="-1,-1,-1,0"
652+
HorizontalAlignment="Stretch" VerticalAlignment="Center"
653+
FontWeight="Bold"
654+
Focusable="False" />
655+
656+
<Grid x:Name="PART_MonthView" Grid.Row="1" Grid.ColumnSpan="3" Visibility="Visible" Margin="8" HorizontalAlignment="Center">
657+
<Grid.RowDefinitions>
658+
<RowDefinition Height="Auto"/>
659+
<RowDefinition Height="Auto"/>
660+
<RowDefinition Height="Auto"/>
661+
<RowDefinition Height="Auto"/>
662+
<RowDefinition Height="Auto"/>
663+
<RowDefinition Height="Auto"/>
664+
<RowDefinition Height="Auto"/>
665+
</Grid.RowDefinitions>
666+
<Grid.ColumnDefinitions>
667+
<ColumnDefinition Width="Auto"/>
668+
<ColumnDefinition Width="Auto"/>
669+
<ColumnDefinition Width="Auto"/>
670+
<ColumnDefinition Width="Auto"/>
671+
<ColumnDefinition Width="Auto"/>
672+
<ColumnDefinition Width="Auto"/>
673+
<ColumnDefinition Width="Auto"/>
674+
</Grid.ColumnDefinitions>
675+
</Grid>
676+
677+
<Grid x:Name="PART_YearView" Grid.Row="1" Grid.ColumnSpan="3" Visibility="Hidden" Margin="8" HorizontalAlignment="Center">
678+
<Grid.RowDefinitions>
679+
<RowDefinition Height="Auto"/>
680+
<RowDefinition Height="Auto"/>
681+
<RowDefinition Height="Auto"/>
682+
</Grid.RowDefinitions>
683+
<Grid.ColumnDefinitions>
684+
<ColumnDefinition Width="Auto"/>
685+
<ColumnDefinition Width="Auto"/>
686+
<ColumnDefinition Width="Auto"/>
687+
<ColumnDefinition Width="Auto"/>
688+
</Grid.ColumnDefinitions>
689+
</Grid>
690+
</Grid>
691+
</Border>
692+
</Grid>
693+
<ControlTemplate.Triggers>
694+
<DataTrigger Value="Year">
695+
<DataTrigger.Binding>
696+
<Binding Path="DisplayMode">
697+
<Binding.RelativeSource>
698+
<RelativeSource Mode="FindAncestor" AncestorType="{x:Type Calendar}" />
699+
</Binding.RelativeSource>
700+
</Binding>
701+
</DataTrigger.Binding>
702+
<Setter TargetName="PART_MonthView" Property="Visibility" Value="Hidden" />
703+
<Setter TargetName="PART_YearView" Property="Visibility" Value="Visible" />
704+
</DataTrigger>
705+
<DataTrigger Value="Decade">
706+
<DataTrigger.Binding>
707+
<Binding Path="DisplayMode">
708+
<Binding.RelativeSource>
709+
<RelativeSource Mode="FindAncestor" AncestorType="{x:Type Calendar}" />
710+
</Binding.RelativeSource>
711+
</Binding>
712+
</DataTrigger.Binding>
713+
<Setter TargetName="PART_MonthView" Property="Visibility" Value="Hidden" />
714+
<Setter TargetName="PART_YearView" Property="Visibility" Value="Visible" />
715+
</DataTrigger>
716+
</ControlTemplate.Triggers>
717+
</ControlTemplate>
718+
</Setter.Value>
719+
</Setter>
720+
</Style>
721+
722+
<Style x:Key="MahApps.Styles.CalendarDayButton.Mui" TargetType="CalendarDayButton" >
723+
<Setter Property="MinWidth" Value="5"/>
724+
<Setter Property="MinHeight" Value="5"/>
725+
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}"/>
726+
<Setter Property="HorizontalContentAlignment" Value="Center"/>
727+
<Setter Property="VerticalContentAlignment" Value="Center"/>
728+
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
729+
<Setter Property="Template">
730+
<Setter.Value>
731+
<ControlTemplate TargetType="CalendarDayButton">
732+
<Grid Background="{TemplateBinding Background}">
733+
<ContentPresenter
734+
x:Name="NormalText"
735+
TextElement.Foreground="{TemplateBinding Foreground}"
736+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
737+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
738+
Margin="5,1,5,1" />
739+
<Path x:Name="Blackout" Opacity=".5" Visibility="Collapsed" Margin="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{TemplateBinding Foreground}" Stretch="Fill" 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"/>
740+
<Rectangle x:Name="DayButtonFocusVisual" Visibility="Collapsed" IsHitTestVisible="false" Stroke="{DynamicResource MahApps.Brushes.Accent.Mui}"/>
741+
</Grid>
742+
743+
<ControlTemplate.Triggers>
744+
<Trigger Property="IsFocused" Value="True">
745+
<Setter TargetName="DayButtonFocusVisual" Property="Visibility" Value="Visible" />
746+
</Trigger>
747+
<Trigger Property="IsKeyboardFocused" Value="True">
748+
<Setter TargetName="DayButtonFocusVisual" Property="Visibility" Value="Visible" />
749+
</Trigger>
750+
<Trigger Property="IsMouseOver" Value="True">
751+
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.ButtonBackgroundHover.Mui}" />
752+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextHover.Mui}" />
753+
</Trigger>
754+
<Trigger Property="IsPressed" Value="True">
755+
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.ButtonBackgroundPressed.Mui}" />
756+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextPressed.Mui}" />
757+
</Trigger>
758+
<Trigger Property="IsHighlighted" Value="True">
759+
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.ButtonBackgroundPressed.Mui}" />
760+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextPressed.Mui}" />
761+
</Trigger>
762+
<Trigger Property="IsSelected" Value="True">
763+
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.ButtonBackgroundPressed.Mui}" />
764+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextPressed.Mui}" />
765+
</Trigger>
766+
<Trigger Property="IsToday" Value="True">
767+
<Setter TargetName="DayButtonFocusVisual" Property="Visibility" Value="Visible" />
768+
</Trigger>
769+
<Trigger Property="IsInactive" Value="True">
770+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextDisabled.Mui}" />
771+
</Trigger>
772+
<Trigger Property="IsEnabled" Value="False">
773+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextDisabled.Mui}" />
774+
</Trigger>
775+
<Trigger Property="IsBlackedOut" Value="True">
776+
<Setter TargetName="Blackout" Property="Visibility" Value="Visible" />
777+
</Trigger>
778+
</ControlTemplate.Triggers>
779+
</ControlTemplate>
780+
</Setter.Value>
781+
</Setter>
782+
</Style>
783+
784+
<Style x:Key="MahApps.Styles.CalendarButton.Mui" TargetType="CalendarButton" >
785+
<Setter Property="Background" Value="Transparent"/>
786+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonText.Mui}" />
787+
<Setter Property="MinWidth" Value="40"/>
788+
<Setter Property="MinHeight" Value="42"/>
789+
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}"/>
790+
<Setter Property="HorizontalContentAlignment" Value="Center"/>
791+
<Setter Property="VerticalContentAlignment" Value="Center"/>
792+
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
793+
<Setter Property="Template">
794+
<Setter.Value>
795+
<ControlTemplate TargetType="CalendarButton">
796+
<Grid Background="{TemplateBinding Background}">
797+
<ContentPresenter x:Name="NormalText"
798+
TextElement.Foreground="{TemplateBinding Foreground}"
799+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
800+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
801+
Margin="1,0,1,1" />
802+
<Rectangle x:Name="CalendarButtonFocusVisual" Visibility="Collapsed" IsHitTestVisible="false" Stroke="{DynamicResource MahApps.Brushes.Accent.Mui}" />
803+
</Grid>
804+
<ControlTemplate.Triggers>
805+
<Trigger Property="IsFocused" Value="True">
806+
<Setter TargetName="CalendarButtonFocusVisual" Property="Visibility" Value="Visible" />
807+
</Trigger>
808+
<Trigger Property="IsKeyboardFocused" Value="True">
809+
<Setter TargetName="CalendarButtonFocusVisual" Property="Visibility" Value="Visible" />
810+
</Trigger>
811+
<Trigger Property="IsMouseOver" Value="True">
812+
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.ButtonBackgroundHover.Mui}" />
813+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextHover.Mui}" />
814+
</Trigger>
815+
<Trigger Property="IsPressed" Value="True">
816+
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.ButtonBackgroundPressed.Mui}" />
817+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextPressed.Mui}" />
818+
</Trigger>
819+
<Trigger Property="HasSelectedDays" Value="True">
820+
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.ButtonBackgroundPressed.Mui}" />
821+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextPressed.Mui}" />
822+
</Trigger>
823+
<Trigger Property="IsInactive" Value="True">
824+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextDisabled.Mui}" />
825+
</Trigger>
826+
<Trigger Property="IsEnabled" Value="False">
827+
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ButtonTextDisabled.Mui}" />
828+
</Trigger>
829+
</ControlTemplate.Triggers>
830+
</ControlTemplate>
831+
</Setter.Value>
832+
</Setter>
833+
</Style>
834+
570835
</ResourceDictionary>

0 commit comments

Comments
 (0)