feat: add tooltip error theme.
This commit is contained in:
parent
6eb405abe2
commit
97b5eb7a04
@ -65,6 +65,19 @@
|
|||||||
<system:Exception />
|
<system:Exception />
|
||||||
</DataValidationErrors.Error>
|
</DataValidationErrors.Error>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
|
<TextBox
|
||||||
|
Width="300"
|
||||||
|
InnerLeftContent="http://"
|
||||||
|
InnerRightContent=".com">
|
||||||
|
<TextBox.Styles>
|
||||||
|
<Style Selector="TextBox /template/ DataValidationErrors">
|
||||||
|
<Setter Property="Theme" Value="{DynamicResource TooltipDataValidationErrors}" />
|
||||||
|
</Style>
|
||||||
|
</TextBox.Styles>
|
||||||
|
<DataValidationErrors.Error>
|
||||||
|
<system:Exception />
|
||||||
|
</DataValidationErrors.Error>
|
||||||
|
</TextBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -14,6 +14,13 @@
|
|||||||
BasedOn="{StaticResource {x:Type TextBox}}"
|
BasedOn="{StaticResource {x:Type TextBox}}"
|
||||||
TargetType="TextBox">
|
TargetType="TextBox">
|
||||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||||
|
<Setter Property="MinHeight" Value="20" />
|
||||||
|
<Style Selector="^ /template/ Border#PART_ContentPresenterBorder">
|
||||||
|
<Setter Property="MinHeight" Value="20" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^:error:focus /template/ Border#PART_ContentPresenterBorder">
|
||||||
|
<Setter Property="Border.BorderBrush" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
<Style Selector="^ /template/ DataValidationErrors">
|
<Style Selector="^ /template/ DataValidationErrors">
|
||||||
<Setter Property="Theme" Value="{DynamicResource TooltipDataValidationErrors}" />
|
<Setter Property="Theme" Value="{DynamicResource TooltipDataValidationErrors}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
<ResourceDictionary
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:collections="clr-namespace:System.Collections;assembly=netstandard">
|
||||||
<!-- Add Resources Here -->
|
<!-- Add Resources Here -->
|
||||||
<ControlTheme x:Key="{x:Type DataValidationErrors}" TargetType="DataValidationErrors">
|
<ControlTheme x:Key="{x:Type DataValidationErrors}" TargetType="DataValidationErrors">
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
@ -52,4 +55,54 @@
|
|||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TooltipDataValidationErrors" TargetType="DataValidationErrors">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate 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}"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}" />
|
||||||
|
</DockPanel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
<Setter Property="ErrorTemplate">
|
||||||
|
<DataTemplate>
|
||||||
|
<Panel Name="PART_InlineErrorTemplatePanel" Background="Transparent">
|
||||||
|
<Panel.Styles>
|
||||||
|
<Style Selector="Panel#PART_InlineErrorTemplatePanel">
|
||||||
|
<Setter Property="Margin" Value="8,0" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Panel#PART_InlineErrorTemplatePanel ToolTip">
|
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsForeground}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Panel#PART_InlineErrorTemplatePanel ToolTip TextBlock">
|
||||||
|
<Setter Property="TextWrapping" Value="Wrap" />
|
||||||
|
</Style>
|
||||||
|
</Panel.Styles>
|
||||||
|
<ToolTip.Tip>
|
||||||
|
<ItemsControl x:DataType="collections:IEnumerable" ItemsSource="{Binding}" />
|
||||||
|
</ToolTip.Tip>
|
||||||
|
<Path
|
||||||
|
Width="14"
|
||||||
|
Height="14"
|
||||||
|
Data="M14,7 A7,7 0 0,0 0,7 M0,7 A7,7 0 1,0 14,7 M7,3l0,5 M7,9l0,2"
|
||||||
|
Stroke="{DynamicResource DataValidationErrorsForeground}"
|
||||||
|
StrokeThickness="2" />
|
||||||
|
</Panel>
|
||||||
|
</DataTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user