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 IsEnabled="False" />
<DatePicker Classes="Large" /> <DatePicker Classes="Large" />
<DatePicker Classes="Small" /> <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> </StackPanel>
</UserControl> </UserControl>

View File

@ -15,5 +15,16 @@
<TimePicker ClockIdentifier="12HourClock" IsEnabled="False" /> <TimePicker ClockIdentifier="12HourClock" IsEnabled="False" />
<TimePicker Classes="Large" /> <TimePicker Classes="Large" />
<TimePicker Classes="Small" /> <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> </StackPanel>
</UserControl> </UserControl>

View File

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

View File

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

View File

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

View File

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