|
|
|
@ -14,8 +14,7 @@ |
|
|
|
<TextBox Text="Sample"> |
|
|
|
<TextBox.Styles> |
|
|
|
<Style Selector="DataValidationErrors"> |
|
|
|
<Setter Property="Template" Value="{DynamicResource TooltipDataValidationContentTemplate}" /> |
|
|
|
<Setter Property="ErrorTemplate" Value="{DynamicResource TooltipDataValidationErrorTemplate}" /> |
|
|
|
<Setter Property="Theme" Value="{DynamicResource TooltipDataValidationErrors}" /> |
|
|
|
</Style> |
|
|
|
</TextBox.Styles> |
|
|
|
<DataValidationErrors.Error> |
|
|
|
@ -26,10 +25,33 @@ |
|
|
|
</Border> |
|
|
|
</Design.PreviewWith> |
|
|
|
|
|
|
|
<ControlTheme x:Key="{x:Type DataValidationErrors}" TargetType="DataValidationErrors"> |
|
|
|
<ControlTheme.Resources> |
|
|
|
<DataTemplate x:Key="InlineDataValidationErrorTemplate"> |
|
|
|
<ItemsControl Items="{Binding}" x:DataType="DataValidationErrors" Foreground="{DynamicResource SystemControlErrorTextForegroundBrush}"> |
|
|
|
<ControlTheme x:Key="{x:Type DataValidationErrors}" |
|
|
|
TargetType="DataValidationErrors"> |
|
|
|
<Setter Property="Template"> |
|
|
|
<ControlTemplate TargetType="DataValidationErrors"> |
|
|
|
<DockPanel LastChildFill="True"> |
|
|
|
<ContentControl x:Name="InlineDataValidationContentControl" |
|
|
|
Margin="0,4,0,0" |
|
|
|
Content="{Binding (DataValidationErrors.Errors)}" |
|
|
|
ContentTemplate="{TemplateBinding ErrorTemplate}" |
|
|
|
DataContext="{TemplateBinding Owner}" |
|
|
|
DockPanel.Dock="Bottom" |
|
|
|
IsVisible="{Binding (DataValidationErrors.HasErrors)}" /> |
|
|
|
<ContentPresenter Name="PART_ContentPresenter" |
|
|
|
Padding="{TemplateBinding Padding}" |
|
|
|
Background="{TemplateBinding Background}" |
|
|
|
BorderThickness="{TemplateBinding BorderThickness}" |
|
|
|
Content="{TemplateBinding Content}" |
|
|
|
ContentTemplate="{TemplateBinding ContentTemplate}" |
|
|
|
CornerRadius="{TemplateBinding CornerRadius}" /> |
|
|
|
</DockPanel> |
|
|
|
</ControlTemplate> |
|
|
|
</Setter> |
|
|
|
<Setter Property="ErrorTemplate"> |
|
|
|
<DataTemplate> |
|
|
|
<ItemsControl x:DataType="DataValidationErrors" |
|
|
|
Foreground="{DynamicResource SystemControlErrorTextForegroundBrush}" |
|
|
|
Items="{Binding}"> |
|
|
|
<ItemsControl.Styles> |
|
|
|
<Style Selector="TextBlock"> |
|
|
|
<Setter Property="TextWrapping" Value="Wrap" /> |
|
|
|
@ -37,27 +59,34 @@ |
|
|
|
</ItemsControl.Styles> |
|
|
|
</ItemsControl> |
|
|
|
</DataTemplate> |
|
|
|
<ControlTemplate x:Key="InlineDataValidationContentTemplate" TargetType="DataValidationErrors"> |
|
|
|
</Setter> |
|
|
|
</ControlTheme> |
|
|
|
|
|
|
|
<ControlTheme x:Key="TooltipDataValidationErrors" |
|
|
|
TargetType="DataValidationErrors"> |
|
|
|
<Setter Property="Template"> |
|
|
|
<ControlTemplate TargetType="DataValidationErrors"> |
|
|
|
<DockPanel LastChildFill="True"> |
|
|
|
<ContentControl x:Name="InlineDataValidationContentControl" |
|
|
|
Margin="0,4,0,0" |
|
|
|
Content="{Binding (DataValidationErrors.Errors)}" |
|
|
|
<ContentControl Content="{Binding (DataValidationErrors.Errors)}" |
|
|
|
ContentTemplate="{TemplateBinding ErrorTemplate}" |
|
|
|
DataContext="{TemplateBinding Owner}" |
|
|
|
DockPanel.Dock="Bottom" |
|
|
|
DockPanel.Dock="Right" |
|
|
|
IsVisible="{Binding (DataValidationErrors.HasErrors)}" /> |
|
|
|
<ContentPresenter Name="PART_ContentPresenter" |
|
|
|
Padding="{TemplateBinding Padding}" |
|
|
|
Background="{TemplateBinding Background}" |
|
|
|
BorderBrush="{TemplateBinding BorderBrush}" |
|
|
|
BorderThickness="{TemplateBinding BorderThickness}" |
|
|
|
CornerRadius="{TemplateBinding CornerRadius}" |
|
|
|
Content="{TemplateBinding Content}" |
|
|
|
ContentTemplate="{TemplateBinding ContentTemplate}" /> |
|
|
|
ContentTemplate="{TemplateBinding ContentTemplate}" |
|
|
|
CornerRadius="{TemplateBinding CornerRadius}" /> |
|
|
|
</DockPanel> |
|
|
|
</ControlTemplate> |
|
|
|
|
|
|
|
<DataTemplate x:DataType="DataValidationErrors" x:Key="TooltipDataValidationErrorTemplate"> |
|
|
|
<Panel Name="PART_InlineErrorTemplatePanel" Background="Transparent"> |
|
|
|
</Setter> |
|
|
|
<Setter Property="ErrorTemplate"> |
|
|
|
<DataTemplate> |
|
|
|
<Panel Name="PART_InlineErrorTemplatePanel" |
|
|
|
Background="Transparent"> |
|
|
|
<Panel.Styles> |
|
|
|
<Style Selector="Panel#PART_InlineErrorTemplatePanel"> |
|
|
|
<Setter Property="Margin" Value="8,0" /> |
|
|
|
@ -70,7 +99,7 @@ |
|
|
|
</Style> |
|
|
|
</Panel.Styles> |
|
|
|
<ToolTip.Tip> |
|
|
|
<ItemsControl Items="{Binding}" /> |
|
|
|
<ItemsControl Items="{ReflectionBinding}" /> |
|
|
|
</ToolTip.Tip> |
|
|
|
<Path Width="14" |
|
|
|
Height="14" |
|
|
|
@ -79,25 +108,6 @@ |
|
|
|
StrokeThickness="2" /> |
|
|
|
</Panel> |
|
|
|
</DataTemplate> |
|
|
|
<ControlTemplate x:Key="TooltipDataValidationContentTemplate" TargetType="DataValidationErrors"> |
|
|
|
<DockPanel LastChildFill="True"> |
|
|
|
<ContentControl Content="{Binding (DataValidationErrors.Errors)}" |
|
|
|
ContentTemplate="{TemplateBinding ErrorTemplate}" |
|
|
|
DataContext="{TemplateBinding Owner}" |
|
|
|
DockPanel.Dock="Right" |
|
|
|
IsVisible="{Binding (DataValidationErrors.HasErrors)}" /> |
|
|
|
<ContentPresenter Name="PART_ContentPresenter" |
|
|
|
Padding="{TemplateBinding Padding}" |
|
|
|
Background="{TemplateBinding Background}" |
|
|
|
BorderBrush="{TemplateBinding BorderBrush}" |
|
|
|
BorderThickness="{TemplateBinding BorderThickness}" |
|
|
|
CornerRadius="{TemplateBinding CornerRadius}" |
|
|
|
Content="{TemplateBinding Content}" |
|
|
|
ContentTemplate="{TemplateBinding ContentTemplate}" /> |
|
|
|
</DockPanel> |
|
|
|
</ControlTemplate> |
|
|
|
</ControlTheme.Resources> |
|
|
|
<Setter Property="Template" Value="{StaticResource InlineDataValidationContentTemplate}" /> |
|
|
|
<Setter Property="ErrorTemplate" Value="{StaticResource InlineDataValidationErrorTemplate}" /> |
|
|
|
</Setter> |
|
|
|
</ControlTheme> |
|
|
|
</ResourceDictionary> |
|
|
|
|