-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDataValidationView.xaml
More file actions
82 lines (75 loc) · 2.91 KB
/
DataValidationView.xaml
File metadata and controls
82 lines (75 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ApplicationTemplate">
<Style TargetType="local:DataValidationView"
x:Key="DefaultDataValidationViewStyle">
<Setter Property="Margin"
Value="0" />
<Setter Property="Padding"
Value="0" />
<Setter Property="VerticalAlignment"
Value="Stretch" />
<Setter Property="HorizontalAlignment"
Value="Stretch" />
<Setter Property="VerticalContentAlignment"
Value="Stretch" />
<Setter Property="HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:DataValidationView">
<Grid x:Name="RootGrid"
AutomationProperties.Name="{Binding State, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource DataValidationStateToVoiceOverString}}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ValidationStates">
<VisualState x:Name="Default" />
<VisualState x:Name="Valid" />
<VisualState x:Name="Error">
<VisualState.Setters>
<Setter Target="ErrorBorder.Opacity"
Value="1" />
<Setter Target="Errors.Opacity"
Value="1" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Content -->
<ContentPresenter x:Name="ContentPresenter"
Content="{TemplateBinding Content}"
ContentTransitions="{TemplateBinding ContentTransitions}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw" />
<!-- Error border -->
<Border x:Name="ErrorBorder"
Opacity="0"
BorderBrush="{StaticResource ErrorBrush}"
CornerRadius="4"
BorderThickness="2" />
<Grid x:Name="Errors"
Grid.Row="1"
Margin="0,5">
<ItemsControl ItemsSource="{Binding State.Errors, RelativeSource={RelativeSource TemplatedParent}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ErrorMessage}"
Style="{StaticResource BodySmall}"
Foreground="{StaticResource ErrorBrush}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="local:DataValidationView"
BasedOn="{StaticResource DefaultDataValidationViewStyle}" />
</ResourceDictionary>