resources/xaml/styles/DatePickerStyle.xaml
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ControlTemplate x:Key="CalendarPreviousButtonTemplate" TargetType="Button"> <Border Background="Transparent" Width="30" Height="30"> <Path Data="M 8,5 L 2,11 L 8,17" Stroke="{TemplateBinding Foreground}" StrokeThickness="2" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True"/> </Border> </ControlTemplate> <ControlTemplate x:Key="CalendarNextButtonTemplate" TargetType="Button"> <Border Background="Transparent" Width="30" Height="30"> <Path Data="M 2,5 L 8,11 L 2,17" Stroke="{TemplateBinding Foreground}" StrokeThickness="2" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True"/> </Border> </ControlTemplate> <ControlTemplate x:Key="CalendarHeaderButtonTemplate" TargetType="Button"> <Border Background="Transparent" Padding="8,4,8,4" CornerRadius="4"> <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" TextElement.FontWeight="SemiBold" TextElement.FontSize="14" TextElement.Foreground="{TemplateBinding Foreground}"/> </Border> </ControlTemplate> <Style x:Key="ModernCalendarDayButtonStyle" TargetType="CalendarDayButton"> <Setter Property="MinWidth" Value="34"/> <Setter Property="MinHeight" Value="34"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="Foreground" Value="{DynamicResource ControlForegroundBrush}"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontSize" Value="13"/> <Setter Property="Margin" Value="1"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="CalendarDayButton"> <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="17"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="border" Property="Background" Value="{DynamicResource SelectionBackgroundBrush}"/> <Setter Property="Foreground" Value="{DynamicResource SelectionForegroundBrush}"/> </Trigger> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="border" Property="Background" Value="{DynamicResource AccentBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ButtonForegroundBrush}"/> </Trigger> <Trigger Property="IsToday" Value="True"> <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource AccentBrush}"/> <Setter TargetName="border" Property="BorderThickness" Value="2"/> </Trigger> <Trigger Property="IsInactive" Value="True"> <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/> <Setter Property="Opacity" Value="0.4"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="ModernCalendarButtonStyle" TargetType="CalendarButton"> <Setter Property="Background" Value="Transparent"/> <Setter Property="Foreground" Value="{DynamicResource ControlForegroundBrush}"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontSize" Value="13"/> <Setter Property="MinHeight" Value="40"/> <Setter Property="MinWidth" Value="50"/> <Setter Property="Margin" Value="2"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="CalendarButton"> <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4"> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" TextBlock.Foreground="{TemplateBinding Foreground}"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="border" Property="Background" Value="{DynamicResource SelectionBackgroundBrush}"/> <Setter Property="Foreground" Value="{DynamicResource SelectionForegroundBrush}"/> </Trigger> <Trigger Property="HasSelectedDays" Value="True"> <Setter TargetName="border" Property="Background" Value="{DynamicResource AccentBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ButtonForegroundBrush}"/> </Trigger> <Trigger Property="IsInactive" Value="True"> <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/> <Setter Property="Opacity" Value="0.4"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- CalendarItem style with full template - properly styled header and navigation --> <Style x:Key="ModernCalendarItemStyle" TargetType="CalendarItem"> <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="Foreground" Value="{DynamicResource ControlForegroundBrush}"/> <Setter Property="Margin" Value="0"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="CalendarItem"> <ControlTemplate.Resources> <DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}"> <TextBlock Foreground="{DynamicResource SecondaryTextBrush}" FontWeight="SemiBold" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,6,0,6" Text="{Binding}"/> </DataTemplate> </ControlTemplate.Resources> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="6"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"/> <VisualState x:Name="Disabled"> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.5" Duration="0"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <!-- Header with navigation --> <Grid Grid.Row="0" Margin="8,8,8,4"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Button x:Name="PART_PreviousButton" Grid.Column="0" Focusable="False" Width="28" Height="28" Background="Transparent" BorderThickness="0" Cursor="Hand"> <Button.Template> <ControlTemplate TargetType="Button"> <Border x:Name="bg" Background="Transparent" CornerRadius="4"> <Path Data="M 10,4 L 4,10 L 10,16" Stroke="{DynamicResource ControlForegroundBrush}" StrokeThickness="2" VerticalAlignment="Center" HorizontalAlignment="Center"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="bg" Property="Background" Value="{DynamicResource SelectionBackgroundBrush}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <Button x:Name="PART_HeaderButton" Grid.Column="1" Focusable="False" Background="Transparent" BorderThickness="0" HorizontalAlignment="Center" IsHitTestVisible="False"> <Button.Template> <ControlTemplate TargetType="Button"> <Border x:Name="bg" Background="Transparent" CornerRadius="4" Padding="12,4"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" TextBlock.FontWeight="SemiBold" TextBlock.FontSize="14" TextBlock.Foreground="{DynamicResource ControlForegroundBrush}"/> </Border> </ControlTemplate> </Button.Template> </Button> <Button x:Name="PART_NextButton" Grid.Column="2" Focusable="False" Width="28" Height="28" Background="Transparent" BorderThickness="0" Cursor="Hand"> <Button.Template> <ControlTemplate TargetType="Button"> <Border x:Name="bg" Background="Transparent" CornerRadius="4"> <Path Data="M 4,4 L 10,10 L 4,16" Stroke="{DynamicResource ControlForegroundBrush}" StrokeThickness="2" VerticalAlignment="Center" HorizontalAlignment="Center"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="bg" Property="Background" Value="{DynamicResource SelectionBackgroundBrush}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> </Grid> <!-- Calendar grids --> <Grid Grid.Row="1" Margin="8,0,8,8"> <Grid x:Name="PART_MonthView" Visibility="Visible"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> </Grid> <Grid x:Name="PART_YearView" Visibility="Hidden"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> </Grid> </Grid> </Grid> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="ModernCalendarStyle" TargetType="Calendar"> <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Foreground" Value="{DynamicResource ControlForegroundBrush}"/> <!-- CalendarItemStyle sets colors but keeps default template for proper view switching --> <Setter Property="CalendarItemStyle" Value="{DynamicResource ModernCalendarItemStyle}"/> <Setter Property="CalendarDayButtonStyle" Value="{DynamicResource ModernCalendarDayButtonStyle}"/> <Setter Property="CalendarButtonStyle" Value="{DynamicResource ModernCalendarButtonStyle}"/> </Style> <Style x:Key="ModernDatePickerStyle" TargetType="DatePicker"> <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ControlForegroundBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontSize" Value="12"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="6,0,6,0"/> <Setter Property="CalendarStyle" Value="{DynamicResource ModernCalendarStyle}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="DatePicker"> <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" SnapsToDevicePixels="True"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <DatePickerTextBox x:Name="PART_TextBox" Grid.Column="0" Foreground="{TemplateBinding Foreground}" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Center" Padding="2,0,0,0" Margin="0"> <DatePickerTextBox.Style> <Style TargetType="DatePickerTextBox"> <Setter Property="Background" Value="Transparent"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="DatePickerTextBox"> <Grid> <ContentControl x:Name="PART_Watermark" Focusable="False" IsHitTestVisible="False" Opacity="0.5" Padding="{TemplateBinding Padding}" VerticalAlignment="Center" Content="{TemplateBinding Watermark}" Visibility="Collapsed"/> <ScrollViewer x:Name="PART_ContentHost" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" VerticalAlignment="Center" Margin="0"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="Text" Value=""> <Setter TargetName="PART_Watermark" Property="Visibility" Value="Visible"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </DatePickerTextBox.Style> </DatePickerTextBox> <ToggleButton x:Name="PART_Button" Grid.Column="1" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Background="Transparent" BorderThickness="0" Width="24" Foreground="{TemplateBinding Foreground}" Focusable="False"> <ToggleButton.Template> <ControlTemplate TargetType="ToggleButton"> <Border Background="Transparent"> <Path Data="M 0,0 L 4,4 L 8,0 Z" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="8" Height="4" Stretch="Fill"/> </Border> </ControlTemplate> </ToggleButton.Template> </ToggleButton> <Popup x:Name="PART_Popup" AllowsTransparency="True" Placement="Bottom" StaysOpen="False"> <Border Background="{DynamicResource ControlBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="6" Padding="4" Margin="0,4,0,0"> <Border.Effect> <DropShadowEffect Color="Black" Direction="270" ShadowDepth="4" BlurRadius="12" Opacity="0.3"/> </Border.Effect> <Calendar x:Name="PART_Calendar" Style="{DynamicResource ModernCalendarStyle}"/> </Border> </Popup> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource AccentBrush}"/> </Trigger> <Trigger Property="IsDropDownOpen" Value="True"> <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource AccentBrush}"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/> <Setter Property="Opacity" Value="0.6"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> |