|
2 | 2 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
3 | 3 | xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
|
4 | 4 |
|
| 5 | + <ResourceDictionary.MergedDictionaries> |
| 6 | + <ResourceDictionary Source="MaterialDesignTheme.ValidationErrorTemplate.xaml" /> |
| 7 | + </ResourceDictionary.MergedDictionaries> |
| 8 | + |
5 | 9 | <Style x:Key="MaterialDesignPasswordBox" TargetType="{x:Type PasswordBox}">
|
6 | 10 | <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
|
7 | 11 | <Setter Property="FontFamily" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.FontFamily)}"/>
|
|
13 | 17 | <Setter Property="CaretBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderBrush}"/>
|
14 | 18 | <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
|
15 | 19 | <Setter Property="HorizontalContentAlignment" Value="Left"/>
|
| 20 | + <Setter Property="VerticalContentAlignment" Value="Center"/> |
16 | 21 | <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
17 | 22 | <Setter Property="AllowDrop" Value="true"/>
|
18 | 23 | <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
|
19 | 24 | <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
20 | 25 | <Setter Property="wpf:PasswordFieldAssist.Managed" Value="{Binding RelativeSource={RelativeSource Self}}" />
|
21 |
| - <Setter Property="Validation.ErrorTemplate"> |
22 |
| - <Setter.Value> |
23 |
| - <ControlTemplate> |
24 |
| - <StackPanel> |
25 |
| - <AdornedElementPlaceholder /> |
26 |
| - <TextBlock FontSize="10" Foreground="#f44336" Text="{Binding Path=[0].ErrorContent}" /> |
27 |
| - </StackPanel> |
28 |
| - </ControlTemplate> |
29 |
| - </Setter.Value> |
30 |
| - </Setter> |
| 26 | + <Setter Property="Validation.ErrorTemplate" Value="{StaticResource MaterialDesignValidationErrorTemplate}"/> |
31 | 27 | <Setter Property="Template">
|
32 | 28 | <Setter.Value>
|
33 | 29 | <ControlTemplate TargetType="{x:Type PasswordBox}">
|
34 |
| - <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True" |
35 |
| - Padding="0 4 0 4" VerticalAlignment="Center"> |
36 |
| - <Grid> |
37 |
| - <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" |
38 |
| - TextElement.FontFamily="Times New Roman" /> |
39 |
| - <TextBlock Text="{Binding Path=(wpf:TextFieldAssist.Hint), RelativeSource={RelativeSource TemplatedParent}}" |
40 |
| - Visibility="{Binding Path=(wpf:PasswordFieldAssist.HintVisibility), RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" |
41 |
| - Margin="1 0 1 0" |
42 |
| - x:Name="Hint" |
43 |
| - Opacity="{Binding Path=(wpf:TextFieldAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}" /> |
44 |
| - </Grid> |
45 |
| - </Border> |
| 30 | + <Grid VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> |
| 31 | + <Border x:Name="border" |
| 32 | + BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" |
| 33 | + Background="{TemplateBinding Background}" |
| 34 | + SnapsToDevicePixels="True" |
| 35 | + Padding="0 4 0 4" VerticalAlignment="Center"> |
| 36 | + <Grid Margin="{TemplateBinding Padding}"> |
| 37 | + <ScrollViewer x:Name="PART_ContentHost" |
| 38 | + Focusable="false" |
| 39 | + HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" |
| 40 | + TextElement.FontFamily="Times New Roman" /> |
| 41 | + <TextBlock Text="{Binding Path=(wpf:TextFieldAssist.Hint), RelativeSource={RelativeSource TemplatedParent}}" |
| 42 | + Visibility="{Binding Path=(wpf:PasswordFieldAssist.HintVisibility), RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" |
| 43 | + Margin="1 0 1 0" |
| 44 | + IsHitTestVisible="False" |
| 45 | + x:Name="Hint" |
| 46 | + Opacity="{Binding Path=(wpf:TextFieldAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}" /> |
| 47 | + </Grid> |
| 48 | + </Border> |
| 49 | + <wpf:Underline x:Name="Underline"/> |
| 50 | + </Grid> |
46 | 51 | <ControlTemplate.Triggers>
|
47 | 52 | <Trigger Property="IsEnabled" Value="false">
|
48 | 53 | <Setter Property="Opacity" TargetName="border" Value="0.56"/>
|
|
51 | 56 | <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
|
52 | 57 | </Trigger>
|
53 | 58 | <Trigger Property="IsKeyboardFocused" Value="true">
|
54 |
| - <Setter TargetName="border" Property="Padding" Value="0 4 0 3"/> |
55 |
| - <Setter Property="BorderThickness" Value="0 0 0 2"/> |
56 | 59 | <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
|
57 | 60 | </Trigger>
|
58 | 61 | <Trigger Property="Validation.HasError" Value="true">
|
59 |
| - <Setter Property="BorderBrush" Value="#f44336"/> |
| 62 | + <Setter Property="BorderBrush" Value="{DynamicResource ValidationErrorBrush}"/> |
| 63 | + <Setter TargetName="Underline" Property="Background" Value="{DynamicResource ValidationErrorBrush}"/> |
60 | 64 | </Trigger>
|
61 | 65 | </ControlTemplate.Triggers>
|
62 | 66 | </ControlTemplate>
|
|
0 commit comments