功能完善
This commit is contained in:
371
NeuWPF/NeoUI/Controls/CalendarStyle.xaml
Normal file
371
NeuWPF/NeoUI/Controls/CalendarStyle.xaml
Normal file
@@ -0,0 +1,371 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:assists="clr-namespace:NeumUI.Assists"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../Assets/CommonGeometry.xaml" />
|
||||
<ResourceDictionary Source="FlattenButton.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- 年月按钮 -->
|
||||
<Style TargetType="{x:Type CalendarButton}" x:Key="CalendarButtonDefault">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="MinWidth" Value="48" />
|
||||
<Setter Property="MinHeight" Value="42" />
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type CalendarButton}">
|
||||
<Grid>
|
||||
<Rectangle
|
||||
Fill="{DynamicResource ControlBackgroundSelectedBrush}"
|
||||
Margin="2"
|
||||
RadiusX="4"
|
||||
RadiusY="4"
|
||||
StrokeThickness="{TemplateBinding BorderThickness}"
|
||||
Visibility="Hidden"
|
||||
x:Name="SelectionMark" />
|
||||
<Border
|
||||
Background="{DynamicResource PrimaryNormalBrush}"
|
||||
CornerRadius="4"
|
||||
Margin="2"
|
||||
Visibility="Hidden"
|
||||
x:Name="SelectedBorder" />
|
||||
<ContentPresenter
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
TextElement.Foreground="{DynamicResource TextPrimaryBrush}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="NormalText" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="HasSelectedDays" Value="True">
|
||||
<Setter Property="Visibility" TargetName="SelectedBorder" Value="Visible" />
|
||||
<Setter Property="TextElement.Foreground" TargetName="NormalText" Value="{DynamicResource TextOnAccentPrimaryBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Visibility" TargetName="SelectionMark" Value="Visible" />
|
||||
<Setter Property="Background" TargetName="SelectedBorder" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsInactive" Value="True">
|
||||
<Setter Property="TextElement.Foreground" TargetName="NormalText" Value="{DynamicResource TextSecondaryBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<!-- 日期按钮 -->
|
||||
<Style TargetType="{x:Type CalendarDayButton}" x:Key="CalendarDayButtonDefault">
|
||||
<Setter Property="MinWidth" Value="28" />
|
||||
<Setter Property="MinHeight" Value="26" />
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type CalendarDayButton}">
|
||||
<Grid>
|
||||
<!-- 选中背景 -->
|
||||
<Rectangle
|
||||
Fill="{DynamicResource ControlBackgroundSelectedBrush}"
|
||||
RadiusX="4"
|
||||
RadiusY="4"
|
||||
Visibility="Hidden"
|
||||
x:Name="SelectedBackground" />
|
||||
|
||||
<!-- 鼠标划过背景 -->
|
||||
<Rectangle
|
||||
Fill="{DynamicResource ControlBackgroundHoverBrush}"
|
||||
RadiusX="4"
|
||||
RadiusY="4"
|
||||
Visibility="Hidden"
|
||||
x:Name="HighlightBackground" />
|
||||
|
||||
<!-- 今日背景 -->
|
||||
<Rectangle
|
||||
Fill="{DynamicResource PrimaryNormalBrush}"
|
||||
RadiusX="4"
|
||||
RadiusY="4"
|
||||
Stroke="{DynamicResource PrimaryVariantBrush}"
|
||||
StrokeThickness="0"
|
||||
Visibility="Hidden"
|
||||
x:Name="TodayBackground" />
|
||||
|
||||
<ContentPresenter
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="5,1,5,1"
|
||||
TextElement.Foreground="{DynamicResource TextPrimaryBrush}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="NormalText" />
|
||||
<!-- 叉 -->
|
||||
<Path
|
||||
Data="M0,10 L10,0"
|
||||
Margin="4"
|
||||
Opacity="0"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Stretch="Uniform"
|
||||
Stroke="{DynamicResource ErrorBrush}"
|
||||
StrokeThickness="2"
|
||||
x:Name="Blackout" />
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<!-- 激活状态 -->
|
||||
<VisualStateGroup x:Name="ActiveStates">
|
||||
<VisualStateGroup.Transitions>
|
||||
<VisualTransition GeneratedDuration="0" />
|
||||
</VisualStateGroup.Transitions>
|
||||
<VisualState x:Name="Active" />
|
||||
<VisualState x:Name="Inactive">
|
||||
<Storyboard>
|
||||
<ColorAnimation
|
||||
Duration="0"
|
||||
Storyboard.TargetName="NormalText"
|
||||
Storyboard.TargetProperty="(TextElement.Foreground) .(SolidColorBrush.Color)"
|
||||
To="{DynamicResource TextSecondaryColor}" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Visibility" TargetName="HighlightBackground" Value="Visible" />
|
||||
<Setter Property="Fill" TargetName="TodayBackground" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="StrokeThickness" TargetName="TodayBackground" Value="1" />
|
||||
<Setter Property="Visibility" TargetName="SelectedBackground" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsToday" Value="True">
|
||||
<Setter Property="TextElement.Foreground" TargetName="NormalText" Value="{DynamicResource TextOnAccentPrimaryBrush}" />
|
||||
<Setter Property="Visibility" TargetName="TodayBackground" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsBlackedOut" Value="True">
|
||||
<Setter Property="Visibility" TargetName="Blackout" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<!-- TODO:设置禁用效果 -->
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type CalendarItem}" x:Key="CalendarItemDefault">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type CalendarItem}">
|
||||
<ControlTemplate.Resources>
|
||||
<!-- 星期标题 -->
|
||||
<DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
|
||||
<TextBlock
|
||||
FontFamily="Verdana"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource AdditionalBlueBrush}"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,6,0,6"
|
||||
Text="{Binding}"
|
||||
VerticalAlignment="Center" />
|
||||
</DataTemplate>
|
||||
</ControlTemplate.Resources>
|
||||
<Grid x:Name="PART_Root">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="8"
|
||||
Effect="{DynamicResource PopupShadow}"
|
||||
Margin="4">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="32" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="32" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- 上方背景 -->
|
||||
<Border
|
||||
Background="{DynamicResource PrimaryNormalBrush}"
|
||||
CornerRadius="6,6,0,0"
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="2" />
|
||||
<!-- 向左按钮 -->
|
||||
<Button
|
||||
Background="{DynamicResource PrimaryNormalBrush}"
|
||||
Focusable="False"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Margin="3"
|
||||
Padding="8"
|
||||
Style="{StaticResource FlattenButton}"
|
||||
x:Name="PART_PreviousButton">
|
||||
<Path
|
||||
Data="{StaticResource LeftArrow}"
|
||||
Fill="{DynamicResource TextOnAccentPrimaryBrush}"
|
||||
Height="8"
|
||||
Stretch="Uniform"
|
||||
Width="8" />
|
||||
</Button>
|
||||
<!-- 中间按钮 -->
|
||||
<Button
|
||||
Background="{DynamicResource PrimaryNormalBrush}"
|
||||
Focusable="False"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource TextOnAccentPrimaryBrush}"
|
||||
Grid.Column="1"
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="0,3"
|
||||
Style="{StaticResource FlattenButton}"
|
||||
assists:ShadingAssist.DisabledForeground="{DynamicResource TextOnAccentDisabledBrush}"
|
||||
x:Name="PART_HeaderButton" />
|
||||
<!-- 右侧按钮 -->
|
||||
<Button
|
||||
Background="{DynamicResource PrimaryNormalBrush}"
|
||||
Focusable="False"
|
||||
Grid.Column="2"
|
||||
Grid.Row="0"
|
||||
Margin="3"
|
||||
Padding="8"
|
||||
Style="{StaticResource FlattenButton}"
|
||||
x:Name="PART_NextButton">
|
||||
<Path
|
||||
Data="{StaticResource RightArrow}"
|
||||
Fill="{DynamicResource TextOnAccentPrimaryBrush}"
|
||||
Height="8"
|
||||
Stretch="Uniform"
|
||||
Width="8" />
|
||||
</Button>
|
||||
<!-- 月份视图 -->
|
||||
<Grid
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="6,2,6,6"
|
||||
Visibility="Visible"
|
||||
x:Name="PART_MonthView">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<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>
|
||||
<!-- 年份视图 -->
|
||||
<Grid
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="6,2,6,6"
|
||||
Visibility="Hidden"
|
||||
x:Name="PART_YearView">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!-- 禁用遮罩 -->
|
||||
<Rectangle
|
||||
Fill="{DynamicResource BackgroundLayoutBrush}"
|
||||
Margin="4"
|
||||
Opacity="0"
|
||||
RadiusX="6"
|
||||
RadiusY="6"
|
||||
Stretch="Fill"
|
||||
Visibility="Collapsed"
|
||||
x:Name="PART_DisabledVisual" />
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Duration="0"
|
||||
Storyboard.TargetName="PART_DisabledVisual"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0.5" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Visibility" TargetName="PART_DisabledVisual" Value="Visible" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Year">
|
||||
<Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" />
|
||||
<Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Decade">
|
||||
<Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" />
|
||||
<Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type Calendar}" x:Key="CalendarDefault">
|
||||
<Setter Property="CalendarItemStyle" Value="{StaticResource CalendarItemDefault}" />
|
||||
<Setter Property="CalendarDayButtonStyle" Value="{StaticResource CalendarDayButtonDefault}" />
|
||||
<Setter Property="CalendarButtonStyle" Value="{StaticResource CalendarButtonDefault}" />
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Calendar}">
|
||||
<StackPanel HorizontalAlignment="Center" x:Name="PART_Root">
|
||||
<CalendarItem
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Style="{TemplateBinding CalendarItemStyle}"
|
||||
x:Name="PART_CalendarItem" />
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style BasedOn="{StaticResource CalendarDefault}" TargetType="{x:Type Calendar}" />
|
||||
<Style
|
||||
BasedOn="{StaticResource CalendarDefault}"
|
||||
TargetType="{x:Type Calendar}"
|
||||
x:Key="PickerCalendarStyle">
|
||||
<Setter Property="Margin" Value="8" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user