Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/DatePickerStyle.xaml

248 lines
17 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-08-20 12:10:35 +08:00
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations"
xmlns:sve="clr-namespace:NeoUI.Effects"
2025-07-31 20:12:01 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2025-07-11 09:20:23 +08:00
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CalendarStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:01 +08:00
<Style TargetType="{x:Type DatePickerTextBox}" x:Key="DatePickerTextBoxDefault">
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
2025-08-20 12:10:13 +08:00
<Setter Property="Padding" Value="3" />
2025-07-11 09:20:23 +08:00
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DatePickerTextBox}">
<ControlTemplate.Resources>
2025-07-31 20:12:01 +08:00
<!-- 聚焦对象 -->
2025-07-11 09:20:23 +08:00
<Storyboard x:Key="TextBox.FocusEffect">
2025-07-31 20:12:01 +08:00
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetName="Border"
Storyboard.TargetProperty="Intensity"
To="0.5" />
2025-07-11 09:20:23 +08:00
</Storyboard>
2025-07-31 20:12:01 +08:00
<!-- 取消聚焦对象 -->
2025-07-11 09:20:23 +08:00
<Storyboard x:Key="TextBox.LeaveEffect">
2025-07-31 20:12:01 +08:00
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetName="Border"
Storyboard.TargetProperty="Intensity"
To="0.2" />
2025-07-11 09:20:23 +08:00
</Storyboard>
</ControlTemplate.Resources>
<Grid>
2025-07-31 20:12:01 +08:00
<Grid>
<svd:SlotBorder
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.4"
Padding="{TemplateBinding Padding}"
x:Name="Border">
<ContentControl
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
IsHitTestVisible="False"
2025-08-20 12:10:13 +08:00
Margin="5,0,0,0"
2025-07-31 20:12:01 +08:00
Opacity="0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_Watermark" />
</svd:SlotBorder>
<ScrollViewer
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_ContentHost" />
</Grid>
2025-07-11 09:20:23 +08:00
<VisualStateManager.VisualStateGroups>
2025-07-31 20:12:01 +08:00
<!-- 占位符显示 -->
2025-08-20 12:10:13 +08:00
<!-- https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/datepicker-styles-and-templates -->
<!-- DataPicker自带有这个状态所以可以直接生效 -->
2025-07-11 09:20:23 +08:00
<VisualStateGroup x:Name="WatermarkStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Unwatermarked" />
<VisualState x:Name="Watermarked">
<Storyboard>
2025-07-31 20:12:01 +08:00
<DoubleAnimation
Duration="0"
Storyboard.TargetName="PART_Watermark"
Storyboard.TargetProperty="Opacity"
To="1" />
2025-07-11 09:20:23 +08:00
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="false" />
<Condition Property="IsKeyboardFocused" Value="false" />
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource TextBox.LeaveEffect}" />
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource TextBox.FocusEffect}" />
</MultiTrigger.ExitActions>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-07-31 20:12:01 +08:00
<Style BasedOn="{StaticResource DatePickerTextBoxDefault}" TargetType="{x:Type DatePickerTextBox}" />
2025-07-11 09:20:23 +08:00
<Style TargetType="{x:Type DatePicker}">
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="IsTodayHighlighted" Value="True" />
<Setter Property="SelectedDateFormat" Value="Short" />
2025-08-20 12:10:13 +08:00
<Setter Property="Background" Value="{DynamicResource BackgroundContainerBrush}" />
<Setter Property="Padding" Value="0" />
<!--<Setter Property="Margin" Value="0"/>-->
2025-07-11 09:20:23 +08:00
<Setter Property="CalendarStyle" Value="{StaticResource PickerCalendarStyle}" />
<Setter Property="BorderThickness" Value="1" />
2025-08-20 12:10:13 +08:00
<Setter Property="MinWidth" Value="150" />
2025-07-11 09:20:23 +08:00
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DatePicker}">
<ControlTemplate.Resources>
2025-07-31 20:12:01 +08:00
<Style TargetType="{x:Type Button}" x:Key="CalendarPickerButton">
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="IconBox">
<Grid.RowDefinitions>
2025-07-31 20:12:01 +08:00
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
2025-07-11 09:20:23 +08:00
</Grid.RowDefinitions>
2025-07-31 20:12:01 +08:00
<Border
2025-08-12 23:08:54 +08:00
Background="{DynamicResource PrimaryGradientBrush}"
2025-08-20 12:10:13 +08:00
CornerRadius="3,3,0,0"
2025-07-31 20:12:01 +08:00
Grid.Row="0" />
<Border
2025-08-20 12:10:13 +08:00
Background="{DynamicResource BackgroundLayoutBrush}"
CornerRadius="0,0,3,3"
2025-07-31 20:12:01 +08:00
Grid.Row="1" />
<Path
Data="M380.52,467c-3.87,4.64-7.22,8-16,15.72-4.9,4.65-10,9.29-14.95,13.92 C333.86,511.33,331,515,327.41,527.06h62.14v34.55H281.26V546.92 c0-20.11,5.15-35.32,18.82-50.28,9.54-10.57,20.62-19.85,31.2-29.65, 15.21-13.92,18.3-17.79,18.3-30.16V423.42c0-3.61,0-16.76-13.92-16.5-9.29, 0-12.63,5.41-13.92,9.28-.52,1.55-.78,3.61-.78,7.48V449.2H282.8V425.74 c0-13.66.78-25.78,11.61-36.09,7.22-7,19.85-13.41,42.28-13.41,21.14,0,33, 6.45,40.22,12.38,1.81,1.54,7.22,6.18,10.06,13.14,2.32,5.68,3.09,11.86, 3.09,24.5,0,15.46.51,27.83-9.54,40.73Zm132.27,77.35a34.81,34.81,0,0,1-7.74, 8.25c-14.95,12.38-34.29,12.12-40.22,12.12-20.36,0-32.75-6.45-39.45-12.12 a35.51,35.51,0,0,1-10.57-15.47c-3.1-9-3.1-18-3.1-27.33V427c0-3.35,0-7, .26-10.31.26-4.12,1-15.47,9.29-25,7-8.51,19.08-15.21,42.54-15.21,18.57, 0,42.54,4.38,50.53,24,2.33,5.41,3.1,9.79,3.1,21.14v12.63H479.78V424.7 c0-3.61.52-15.73-13.4-15.73-15.47,0-15.21,12.9-15.21,17.28V460c5.15-5.15, 11.6-11.85,27.84-11.85,22.17,0,33.27,11.08,36.87,19.85,1.81,4.64,2.58, 7.73,2.58,16.76v29.9c0,10.32.26,20.63-5.67,29.66ZM479.53,492c0-3.86, 1.29-18.82-14.18-18.82-3.87,0-6.71.52-9.54,2.84-5.16,4.38-4.9,11.08-4.9, 17V515.2c0,4.65-1,17.54,14.69,17.54,4.9,0,7.23-1.29,9.29-2.84,4.64-3.87, 4.9-10.31,4.9-21.92,0-5.15,0-10.57-.26-16Zm0,0"
2025-08-20 12:10:13 +08:00
Fill="{DynamicResource TextSecondaryBrush}"
2025-07-31 20:12:01 +08:00
Grid.Row="1"
SnapsToDevicePixels="True"
Stretch="Uniform"
Width="12" />
<Path
Data="M353.62,210.77V141.62l-14.84,69.15H318.36l-14.85-69.15v69.15 H283.23V114.66h31l14.3,70.52,14.29-70.52h31.45v96.11Zm75.31,0-3.26-21.92 H407.83l-3.4,21.92H381.69l19.47-96.11h31l19.46,96.11Zm-12-80.86-6.53,42.75 h12.93ZM492.53,177v33.76H469.8V177l-22.88-62.35H469.8 l11.7,42.48,11.71-42.48h23.28Zm0,0"
2025-08-20 12:10:13 +08:00
Fill="{DynamicResource BackgroundLayoutBrush}"
2025-07-31 20:12:01 +08:00
Grid.Row="0"
SnapsToDevicePixels="True"
Stretch="Uniform"
Width="12" />
2025-07-11 09:20:23 +08:00
<Grid.Effect>
2025-07-31 20:12:01 +08:00
<DropShadowEffect
BlurRadius="4"
2025-08-12 23:08:54 +08:00
Color="{DynamicResource DarkShadowColor}"
2025-07-31 20:12:01 +08:00
Opacity="0.6"
ShadowDepth="1" />
2025-07-11 09:20:23 +08:00
</Grid.Effect>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Effect">
<Setter.Value>
<sve:BrightnessContrastEffect Brightness="0.08" />
</Setter.Value>
</Setter>
<Setter Property="Effect" TargetName="IconBox">
<Setter.Value>
2025-07-31 20:12:01 +08:00
<DropShadowEffect
BlurRadius="4"
2025-08-12 23:08:54 +08:00
Color="{DynamicResource DarkShadowColor}"
2025-07-31 20:12:01 +08:00
Opacity="0.4"
ShadowDepth="1" />
2025-07-11 09:20:23 +08:00
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Effect">
<Setter.Value>
<sve:BrightnessContrastEffect Brightness="0.06" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ControlTemplate.Resources>
2025-07-31 20:12:01 +08:00
<Grid
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2025-08-20 12:10:13 +08:00
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="True"
2025-07-31 20:12:01 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_Root">
<DatePickerTextBox
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Focusable="{TemplateBinding Focusable}"
Grid.Column="0"
Grid.Row="0"
HorizontalContentAlignment="Left"
Style="{StaticResource DatePickerTextBoxDefault}"
VerticalContentAlignment="Center"
x:Name="PART_TextBox" />
<Border
Background="Transparent"
HorizontalAlignment="Right"
Width="40" />
<Button
HorizontalAlignment="Right"
2025-08-20 12:10:13 +08:00
Margin="5"
2025-07-31 20:12:01 +08:00
Style="{StaticResource CalendarPickerButton}"
Width="28"
x:Name="PART_Button" />
2025-08-20 12:10:13 +08:00
<!-- Disabled Mask -->
2025-07-31 20:12:01 +08:00
<Border
2025-08-12 23:08:54 +08:00
Background="{DynamicResource BackgroundLayoutBrush}"
2025-07-31 20:12:01 +08:00
CornerRadius="4"
IsHitTestVisible="False"
Margin="4"
Opacity="0"
x:Name="DisabledMask" />
<Popup
AllowsTransparency="True"
Placement="Bottom"
PlacementTarget="{Binding ElementName=PART_Button}"
StaysOpen="False"
x:Name="PART_Popup" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
2025-07-31 20:12:01 +08:00
<Setter Property="Opacity" TargetName="DisabledMask" Value="0.6" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="false">
<Setter Property="Foreground" TargetName="PART_TextBox" Value="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}" />
2025-07-11 09:20:23 +08:00
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>