feat: Small Classes and BackgroundSizing of DateTimePicker, ComboBox TextTrimming.

This commit is contained in:
Zhang Dian 2024-03-27 15:35:13 +08:00
parent 8de7a1ae8c
commit 4e7681d4d4
6 changed files with 44 additions and 17 deletions

View File

@ -14,5 +14,16 @@
<DatePicker IsEnabled="False" />
<DatePicker Classes="Large" />
<DatePicker Classes="Small" />
<StackPanel Orientation="Horizontal">
<DatePicker Classes="Large" />
<DatePicker />
<DatePicker Classes="Small" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<DatePicker IsEnabled="False" />
<DatePicker Classes="Bordered" />
<DatePicker Classes="Bordered" IsEnabled="False" />
</StackPanel>
</StackPanel>
</UserControl>

View File

@ -15,5 +15,16 @@
<TimePicker ClockIdentifier="12HourClock" IsEnabled="False" />
<TimePicker Classes="Large" />
<TimePicker Classes="Small" />
<StackPanel Orientation="Horizontal">
<TimePicker Classes="Large" ClockIdentifier="12HourClock"/>
<TimePicker ClockIdentifier="12HourClock"/>
<TimePicker Classes="Small" ClockIdentifier="12HourClock"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TimePicker IsEnabled="False" />
<TimePicker Classes="Bordered" />
<TimePicker Classes="Bordered" IsEnabled="False" />
</StackPanel>
</StackPanel>
</UserControl>

View File

@ -62,6 +62,7 @@
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
TextTrimming="CharacterEllipsis"
Foreground="{TemplateBinding Foreground}"
IsVisible="{TemplateBinding SelectionBoxItem,
Converter={x:Static ObjectConverters.IsNull}}"

View File

@ -132,6 +132,7 @@
<Setter Property="CornerRadius" Value="{DynamicResource DateTimePickerButtonCornerRadius}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="MinHeight" Value="{DynamicResource DateTimePickerButtonDefaultHeight}" />
<Setter Property="Template">
<ControlTemplate TargetType="DatePicker">
<DataValidationErrors>
@ -145,7 +146,7 @@
Grid.ColumnSpan="2"
Width="298"
MinWidth="298"
MinHeight="{DynamicResource DateTimePickerButtonDefaultHeight}"
MinHeight="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{TemplateBinding Background}"
@ -165,7 +166,7 @@
ColumnDefinitions="78*,Auto,132*,Auto,78*">
<TextBlock
Name="PART_DayTextBlock"
Padding="12,4"
Padding="12,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{TemplateBinding FontFamily}"
@ -174,7 +175,7 @@
Text="day" />
<TextBlock
Name="PART_MonthTextBlock"
Padding="12,4"
Padding="12,0"
VerticalAlignment="Center"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
@ -183,7 +184,7 @@
TextAlignment="Left" />
<TextBlock
Name="PART_YearTextBlock"
Padding="12,4"
Padding="12,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{TemplateBinding FontFamily}"
@ -194,14 +195,16 @@
x:Name="PART_FirstSpacer"
Grid.Column="1"
Width="1"
Margin="0,4"
Height="{TemplateBinding Height}"
MinHeight="{TemplateBinding MinHeight}"
HorizontalAlignment="Center"
Fill="{DynamicResource DateTimePickerSeparatorBackground}" />
<Rectangle
x:Name="PART_SecondSpacer"
Grid.Column="3"
Width="1"
Margin="0,4"
Height="{TemplateBinding Height}"
MinHeight="{TemplateBinding MinHeight}"
HorizontalAlignment="Center"
Fill="{DynamicResource DateTimePickerSeparatorBackground}" />
</Grid>
@ -255,10 +258,10 @@
<Style Selector="^:hasnodate /template/ Button#PART_FlyoutButton TextBlock">
<Setter Property="Foreground" Value="{DynamicResource DateTimePickerEmptyForeground}" />
</Style>
<Style Selector="^.Large /template/ Button#PART_FlyoutButton">
<Style Selector="^.Large">
<Setter Property="MinHeight" Value="{DynamicResource DateTimePickerButtonLargeHeight}" />
</Style>
<Style Selector="^.Small /template/ Button#PART_FlyoutButton">
<Style Selector="^.Small">
<Setter Property="MinHeight" Value="{DynamicResource DateTimePickerButtonSmallHeight}" />
</Style>
</ControlTheme>

View File

@ -6,7 +6,8 @@
<ControlTheme x:Key="DateTimePickerFlyoutButton" TargetType="Button">
<Setter Property="RenderTransform" Value="none" />
<Setter Property="Button.VerticalAlignment" Value="Stretch" />
<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter
@ -14,6 +15,7 @@
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"

View File

@ -136,6 +136,7 @@
<Setter Property="CornerRadius" Value="3" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="MinHeight" Value="{DynamicResource DateTimePickerButtonDefaultHeight}" />
<Setter Property="Template">
<ControlTemplate>
<DataValidationErrors>
@ -149,7 +150,7 @@
Grid.ColumnSpan="2"
Width="242"
MinWidth="242"
MinHeight="{DynamicResource DateTimePickerButtonDefaultHeight}"
MinHeight="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{TemplateBinding Background}"
@ -171,7 +172,7 @@
VerticalAlignment="Stretch">
<TextBlock
x:Name="PART_HourTextBlock"
Padding="12,4"
Padding="12,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{TemplateBinding FontFamily}"
@ -183,7 +184,6 @@
Name="PART_FirstColumnDivider"
Grid.Column="1"
Width="1"
Margin="0,4"
HorizontalAlignment="Center"
Fill="{DynamicResource DateTimePickerSeparatorBackground}" />
@ -194,7 +194,7 @@
VerticalAlignment="Stretch">
<TextBlock
x:Name="PART_MinuteTextBlock"
Padding="12,4"
Padding="12,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{TemplateBinding FontFamily}"
@ -206,7 +206,6 @@
Name="PART_SecondColumnDivider"
Grid.Column="3"
Width="1"
Margin="0,4"
HorizontalAlignment="Center"
Fill="{DynamicResource DateTimePickerSeparatorBackground}" />
@ -217,7 +216,7 @@
VerticalAlignment="Stretch">
<TextBlock
x:Name="PART_PeriodTextBlock"
Padding="12,4"
Padding="12,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{TemplateBinding FontFamily}"
@ -278,10 +277,10 @@
<Setter Property="Foreground" Value="{DynamicResource DateTimePickerEmptyForeground}" />
</Style>
<Style Selector="^.Large /template/ Button#PART_FlyoutButton">
<Style Selector="^.Large">
<Setter Property="MinHeight" Value="{DynamicResource DateTimePickerButtonLargeHeight}" />
</Style>
<Style Selector="^.Small /template/ Button#PART_FlyoutButton">
<Style Selector="^.Small">
<Setter Property="MinHeight" Value="{DynamicResource DateTimePickerButtonSmallHeight}" />
</Style>
</ControlTheme>