feat: Add DatePicker, move some common styles to shared.

This commit is contained in:
rabbitism
2023-01-29 01:04:49 +08:00
parent b9a8bd3a2e
commit 6674ca3715
11 changed files with 311 additions and 36 deletions

View File

@@ -1,31 +1,5 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<ControlTheme x:Key="TimePickerFlyoutButton" TargetType="Button">
<Setter Property="RenderTransform" Value="none" />
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter
Name="PART_ContentPresenter"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
CornerRadius="{TemplateBinding CornerRadius}"
Foreground="{TemplateBinding Foreground}" />
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="BorderBrush" Value="{DynamicResource DateTimePickerButtonPointeroverBorderBrush}" />
</Style>
<Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="BorderBrush" Value="{DynamicResource DateTimePickerButtonDisabledBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource DateTimePickerButtonDisabledBackground}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type TimePickerPresenter}" TargetType="TimePickerPresenter">
<Setter Property="MinWidth" Value="242" />
@@ -57,7 +31,7 @@
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
<DateTimePickerPanel
Name="PART_HourSelector"
ItemHeight="{DynamicResource DateTimePickerListBoxItem}"
ItemHeight="{DynamicResource DateTimePickerListBoxItemHeight}"
PanelType="Hour"
ShouldLoop="True" />
</ScrollViewer>
@@ -69,7 +43,7 @@
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
<DateTimePickerPanel
Name="PART_MinuteSelector"
ItemHeight="{DynamicResource DateTimePickerListBoxItem}"
ItemHeight="{DynamicResource DateTimePickerListBoxItemHeight}"
PanelType="Minute"
ShouldLoop="True" />
</ScrollViewer>
@@ -81,7 +55,7 @@
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
<DateTimePickerPanel
Name="PART_PeriodSelector"
ItemHeight="{DynamicResource DateTimePickerListBoxItem}"
ItemHeight="{DynamicResource DateTimePickerListBoxItemHeight}"
PanelType="TimePeriod"
ShouldLoop="False" />
</ScrollViewer>
@@ -178,7 +152,7 @@
Cursor="Hand"
Foreground="{TemplateBinding Foreground}"
IsEnabled="{TemplateBinding IsEnabled}"
Theme="{StaticResource TimePickerFlyoutButton}">
Theme="{StaticResource DateTimePickerFlyoutButton}">
<Grid ColumnDefinitions="*, Auto">
<Grid Name="PART_FlyoutButtonContentGrid" Grid.Column="0">
<!-- Ignore col defs here, set in code -->
@@ -243,8 +217,8 @@
<PathIcon
Name="PART_Icon"
Grid.Column="1"
Width="12"
Height="12"
Width="16"
Height="16"
Margin="0,0,8,0"
Data="{DynamicResource TimePickerIconGlyph}"
Foreground="{DynamicResource DateTimePickerIconForeground}" />