Skip to content

Commit c0d5345

Browse files
committed
Inspect DatePicker
1 parent 0df05c1 commit c0d5345

File tree

1 file changed

+67
-57
lines changed

1 file changed

+67
-57
lines changed

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<TextBlock Text="{Binding Path=(wpf:TextFieldAssist.Hint), RelativeSource={RelativeSource TemplatedParent}}"
5656
Visibility="{TemplateBinding Text, Converter={StaticResource TextFieldHintVisibilityConverter}}"
5757
x:Name="Hint"
58+
IsHitTestVisible="False"
5859
Margin="1 0 1 0"
5960
Opacity="{Binding Path=(wpf:TextFieldAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}"/>
6061
<ContentControl x:Name="PART_Watermark" Focusable="False" IsHitTestVisible="False" Opacity="0" Visibility="Collapsed" />
@@ -95,73 +96,82 @@
9596
<Setter Property="Template">
9697
<Setter.Value>
9798
<ControlTemplate TargetType="{x:Type DatePicker}">
98-
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"
99-
x:Name="border" Padding="0 4 0 4" SnapsToDevicePixels="True">
100-
<VisualStateManager.VisualStateGroups>
101-
<VisualStateGroup x:Name="CommonStates">
102-
<VisualState x:Name="Normal"/>
103-
<VisualState x:Name="Disabled">
104-
<Storyboard>
105-
<DoubleAnimation Duration="0" To=".56" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_Root"/>
106-
</Storyboard>
107-
</VisualState>
108-
</VisualStateGroup>
109-
</VisualStateManager.VisualStateGroups>
110-
<Grid x:Name="PART_Root" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
111-
Background="Transparent">
112-
<Grid.Resources>
113-
<ControlTemplate x:Key="DropDownButtonTemplate" TargetType="{x:Type Button}">
114-
<Grid Background="Transparent">
115-
<VisualStateManager.VisualStateGroups>
116-
<VisualStateGroup x:Name="CommonStates">
117-
<VisualStateGroup.Transitions>
118-
<VisualTransition GeneratedDuration="0"/>
119-
<VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver"/>
120-
<VisualTransition GeneratedDuration="0:0:0.1" To="Pressed"/>
121-
</VisualStateGroup.Transitions>
122-
<VisualState x:Name="Normal"/>
123-
<VisualState x:Name="MouseOver"/>
124-
<VisualState x:Name="Pressed"/>
125-
<VisualState x:Name="Disabled"/>
126-
</VisualStateGroup>
127-
</VisualStateManager.VisualStateGroups>
128-
<Viewbox>
129-
<Canvas Width="24" Height="24">
130-
<Path Data="M19,19H5V8H19M16,1V3H8V1H6V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H18V1M17,12H12V17H17V12Z" Fill="{TemplateBinding Foreground}" />
131-
</Canvas>
132-
</Viewbox>
133-
</Grid>
134-
</ControlTemplate>
135-
</Grid.Resources>
136-
<Grid.ColumnDefinitions>
137-
<ColumnDefinition Width="*"/>
138-
<ColumnDefinition Width="Auto"/>
139-
</Grid.ColumnDefinitions>
140-
<Button x:Name="PART_Button" Grid.Column="1" Foreground="{TemplateBinding BorderBrush}" Focusable="False" HorizontalAlignment="Right" Margin="4 0 0 -3" Grid.Row="0" Template="{StaticResource DropDownButtonTemplate}" Padding="0"
141-
Height="17" />
142-
<DatePickerTextBox x:Name="PART_TextBox" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="Stretch" Grid.Row="0" VerticalContentAlignment="Center" Style="{DynamicResource MaterialDesignDatePickerTextBox}"
143-
HorizontalAlignment="Stretch" />
144-
<Popup x:Name="PART_Popup" AllowsTransparency="True"
145-
Placement="Custom"
146-
CustomPopupPlacementCallback="{x:Static wpf:CustomPopupPlacementCallbackHelper.LargePopupCallback}"
147-
PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"
148-
PopupAnimation="Fade" />
149-
</Grid>
150-
</Border>
151-
<ControlTemplate.Triggers>
99+
<Grid>
100+
<Border BorderBrush="{TemplateBinding BorderBrush}"
101+
BorderThickness="{TemplateBinding BorderThickness}"
102+
Background="{TemplateBinding Background}"
103+
x:Name="border"
104+
Padding="0 4 0 4"
105+
SnapsToDevicePixels="True">
106+
<VisualStateManager.VisualStateGroups>
107+
<VisualStateGroup x:Name="CommonStates">
108+
<VisualState x:Name="Normal"/>
109+
<VisualState x:Name="Disabled">
110+
<Storyboard>
111+
<DoubleAnimation Duration="0" To=".56" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_Root"/>
112+
</Storyboard>
113+
</VisualState>
114+
</VisualStateGroup>
115+
</VisualStateManager.VisualStateGroups>
116+
<Grid x:Name="PART_Root"
117+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
118+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
119+
Background="Transparent">
120+
<Grid.Resources>
121+
<ControlTemplate x:Key="DropDownButtonTemplate" TargetType="{x:Type Button}">
122+
<Grid Background="Transparent">
123+
<VisualStateManager.VisualStateGroups>
124+
<VisualStateGroup x:Name="CommonStates">
125+
<VisualStateGroup.Transitions>
126+
<VisualTransition GeneratedDuration="0"/>
127+
<VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver"/>
128+
<VisualTransition GeneratedDuration="0:0:0.1" To="Pressed"/>
129+
</VisualStateGroup.Transitions>
130+
<VisualState x:Name="Normal"/>
131+
<VisualState x:Name="MouseOver"/>
132+
<VisualState x:Name="Pressed"/>
133+
<VisualState x:Name="Disabled"/>
134+
</VisualStateGroup>
135+
</VisualStateManager.VisualStateGroups>
136+
<Viewbox>
137+
<Canvas Width="24" Height="24">
138+
<Path Data="M19,19H5V8H19M16,1V3H8V1H6V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H18V1M17,12H12V17H17V12Z" Fill="{TemplateBinding Foreground}" />
139+
</Canvas>
140+
</Viewbox>
141+
</Grid>
142+
</ControlTemplate>
143+
</Grid.Resources>
144+
<Grid.ColumnDefinitions>
145+
<ColumnDefinition Width="*"/>
146+
<ColumnDefinition Width="Auto"/>
147+
</Grid.ColumnDefinitions>
148+
<Button x:Name="PART_Button" Grid.Column="1" Foreground="{TemplateBinding BorderBrush}" Focusable="False" HorizontalAlignment="Right" Margin="4 0 0 -3" Grid.Row="0" Template="{StaticResource DropDownButtonTemplate}" Padding="0"
149+
Height="17" />
150+
<DatePickerTextBox x:Name="PART_TextBox" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="Stretch" Grid.Row="0" VerticalContentAlignment="Center" Style="{DynamicResource MaterialDesignDatePickerTextBox}"
151+
HorizontalAlignment="Stretch" />
152+
<Popup x:Name="PART_Popup" AllowsTransparency="True"
153+
Placement="Custom"
154+
CustomPopupPlacementCallback="{x:Static wpf:CustomPopupPlacementCallbackHelper.LargePopupCallback}"
155+
PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"
156+
PopupAnimation="Fade" />
157+
</Grid>
158+
</Border>
159+
<wpf:Underline x:Name="Underline" BindIsKeyboardFocused="False"/>
160+
</Grid>
161+
<ControlTemplate.Triggers>
152162
<Trigger Property="IsEnabled" Value="false">
153163
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
154164
</Trigger>
155165
<Trigger Property="IsMouseOver" Value="true">
156166
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
157167
</Trigger>
158168
<Trigger Property="IsKeyboardFocusWithin" Value="true">
159-
<Setter TargetName="border" Property="Padding" Value="0 4 0 3"/>
160-
<Setter Property="BorderThickness" Value="0 0 0 2"/>
169+
<Setter TargetName="Underline" Property="IsActive" Value="True"/>
161170
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
162171
</Trigger>
163172
<Trigger Property="Validation.HasError" Value="true">
164-
<Setter Property="BorderBrush" Value="#f44336"/>
173+
<Setter Property="BorderBrush" Value="{DynamicResource ValidationErrorBrush}"/>
174+
<Setter TargetName="Underline" Property="IsActive" Value="{DynamicResource ValidationErrorBrush}"/>
165175
</Trigger>
166176
</ControlTemplate.Triggers>
167177
</ControlTemplate>

0 commit comments

Comments
 (0)