feat: DatePicker&TimePicker validations.

This commit is contained in:
Zhang Dian 2023-05-08 10:19:58 +08:00
parent cece722496
commit e8ef024d59
3 changed files with 199 additions and 174 deletions

View File

@ -135,6 +135,7 @@
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Template">
<ControlTemplate TargetType="DatePicker">
<DataValidationErrors>
<Grid Name="LayoutRoot" Margin="{TemplateBinding Padding}">
<Button
Name="PART_FlyoutButton"
@ -147,6 +148,7 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Cursor="Hand"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
Foreground="{TemplateBinding Foreground}"
IsEnabled="{TemplateBinding IsEnabled}"
Theme="{StaticResource DateTimePickerFlyoutButton}">
@ -219,6 +221,7 @@
</Popup>
</Grid>
</DataValidationErrors>
</ControlTemplate>
</Setter>

View File

@ -30,6 +30,25 @@
<Setter Property="BorderBrush" Value="{DynamicResource DateTimePickerButtonDisabledBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource DateTimePickerButtonDisabledBackground}" />
</Style>
<Style Selector="^:error">
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsBackground}" />
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsPointerOverBackground}" />
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsPressedBackground}" />
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
<Style Selector="^:focus /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsSelectedBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsSelectedBorderBrush}" />
</Style>
</Style>
</ControlTheme>
<!-- Theme for the items displayed in the selectors -->

View File

@ -139,6 +139,7 @@
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Template">
<ControlTemplate>
<DataValidationErrors>
<Grid Name="LayoutRoot" Margin="{TemplateBinding Padding}">
<Button
x:Name="PART_FlyoutButton"
@ -151,6 +152,7 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Cursor="Hand"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
Foreground="{TemplateBinding Foreground}"
IsEnabled="{TemplateBinding IsEnabled}"
Theme="{StaticResource DateTimePickerFlyoutButton}">
@ -239,6 +241,7 @@
<TimePickerPresenter Name="PART_PickerPresenter" />
</Popup>
</Grid>
</DataValidationErrors>
</ControlTemplate>
</Setter>