|
1 | 1 | <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
2 | 2 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
3 |
| - xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"> |
4 |
| - |
| 3 | + xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf" |
| 4 | + xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"> |
| 5 | + <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" TrueValue="Visible" FalseValue="Collapsed"/> |
| 6 | + |
5 | 7 | <ControlTemplate x:Key="MaterialDesignValidationErrorTemplate">
|
6 |
| - <StackPanel> |
7 |
| - <AdornedElementPlaceholder Name="Placeholder" /> |
8 |
| - <wpf:CustomValidationPopup x:Name="ValidationPopup" |
9 |
| - IsOpen="True" |
10 |
| - Placement="Bottom" PlacementTarget="{Binding ElementName=Placeholder}" |
11 |
| - AllowsTransparency="True"> |
12 |
| - <Border Background="{DynamicResource MaterialDesignPaper}"> |
13 |
| - <Border.Resources> |
14 |
| - <DataTemplate DataType="{x:Type ValidationError}"> |
15 |
| - <TextBlock Foreground="{DynamicResource ValidationErrorBrush}" |
| 8 | + <ControlTemplate.Resources> |
| 9 | + <DataTemplate DataType="{x:Type ValidationError}"> |
| 10 | + <TextBlock Foreground="{DynamicResource ValidationErrorBrush}" |
16 | 11 | FontSize="10"
|
17 | 12 | MaxWidth="250"
|
18 | 13 | Margin="2"
|
19 | 14 | TextWrapping="Wrap"
|
20 | 15 | Text="{Binding ErrorContent}"
|
21 | 16 | UseLayoutRounding="false" />
|
22 |
| - </DataTemplate> |
23 |
| - </Border.Resources> |
| 17 | + </DataTemplate> |
| 18 | + </ControlTemplate.Resources> |
| 19 | + <StackPanel> |
| 20 | + <AdornedElementPlaceholder Name="Placeholder" /> |
| 21 | + <Border Name="DefaultErrorViewerWrapper" |
| 22 | + Visibility="Collapsed"> |
| 23 | + <Border Name="DefaultErrorViewer" |
| 24 | + Background="{DynamicResource MaterialDesignPaper}"> |
| 25 | + <ContentPresenter Content="{Binding CurrentItem}" /> |
| 26 | + </Border> |
| 27 | + </Border> |
| 28 | + |
| 29 | + <wpf:CustomValidationPopup x:Name="ValidationPopup" |
| 30 | + IsOpen="False" |
| 31 | + Placement="Bottom" PlacementTarget="{Binding ElementName=Placeholder}" |
| 32 | + AllowsTransparency="True"> |
| 33 | + <Border Background="{DynamicResource MaterialDesignPaper}"> |
24 | 34 | <ContentPresenter Content="{Binding CurrentItem}" />
|
25 | 35 | </Border>
|
26 | 36 | </wpf:CustomValidationPopup>
|
27 | 37 | </StackPanel>
|
28 | 38 | <ControlTemplate.Triggers>
|
29 |
| - <DataTrigger Binding="{Binding ElementName=Placeholder, Path=AdornedElement.(wpf:ValidationAssist.ShowOnFocus)}" Value="True"> |
30 |
| - <Setter TargetName="ValidationPopup" Property="IsOpen" Value="{Binding ElementName=Placeholder, Path=AdornedElement.IsKeyboardFocusWithin, Mode=OneWay}"/> |
| 39 | + <MultiDataTrigger> |
| 40 | + <MultiDataTrigger.Conditions> |
| 41 | + <Condition Binding="{Binding ElementName=Placeholder, Path=AdornedElement.(wpf:ValidationAssist.ShowOnFocus)}" Value="True"/> |
| 42 | + <Condition Binding="{Binding ElementName=Placeholder, Path=AdornedElement.(wpf:ValidationAssist.UsePopup)}" Value="True"/> |
| 43 | + </MultiDataTrigger.Conditions> |
| 44 | + <MultiDataTrigger.Setters> |
| 45 | + <Setter TargetName="ValidationPopup" Property="IsOpen" |
| 46 | + Value="{Binding ElementName=Placeholder, Path=AdornedElement.IsKeyboardFocusWithin, Mode=OneWay}"/> |
| 47 | + </MultiDataTrigger.Setters> |
| 48 | + </MultiDataTrigger> |
| 49 | + |
| 50 | + <MultiDataTrigger> |
| 51 | + <MultiDataTrigger.Conditions> |
| 52 | + <Condition Binding="{Binding ElementName=Placeholder, Path=AdornedElement.(wpf:ValidationAssist.ShowOnFocus)}" Value="True"/> |
| 53 | + <Condition Binding="{Binding ElementName=Placeholder, Path=AdornedElement.(wpf:ValidationAssist.UsePopup)}" Value="False"/> |
| 54 | + </MultiDataTrigger.Conditions> |
| 55 | + <MultiDataTrigger.Setters> |
| 56 | + <Setter TargetName="DefaultErrorViewer" Property="Visibility" |
| 57 | + Value="{Binding ElementName=Placeholder, Path=AdornedElement.IsKeyboardFocusWithin, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"/> |
| 58 | + </MultiDataTrigger.Setters> |
| 59 | + </MultiDataTrigger> |
| 60 | + |
| 61 | + <DataTrigger Binding="{Binding ElementName=Placeholder, Path=AdornedElement.(wpf:ValidationAssist.UsePopup)}" Value="True"> |
| 62 | + <Setter TargetName="ValidationPopup" Property="IsOpen" Value="True"/> |
| 63 | + </DataTrigger> |
| 64 | + |
| 65 | + <DataTrigger Binding="{Binding ElementName=Placeholder, Path=AdornedElement.(wpf:ValidationAssist.UsePopup)}" Value="False"> |
| 66 | + <Setter TargetName="DefaultErrorViewerWrapper" Property="Visibility" Value="Visible"/> |
31 | 67 | </DataTrigger>
|
32 | 68 | </ControlTemplate.Triggers>
|
33 | 69 | </ControlTemplate>
|
|
0 commit comments