Skip to content

Commit 877f16e

Browse files
Update readme file (minor changes)
1 parent 944f13c commit 877f16e

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Images/validation.jpg

22.5 KB
Loading

Readme.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This example validates the input field and displays error indicators in DevExpre
1111

1212
Users can see visual indicators (error, warning, information) directly in the editor. Each indicator includes a descriptive message that helps users quickly fix input mistakes.
1313

14-
GIF
14+
![Indicate Errors and Warnings by Implementing IDataErrorInfo](./Images/validation.jpg)
1515

1616
## Implementation Details
1717

@@ -76,6 +76,46 @@ public class ErrorContentConverter : IValueConverter {
7676
}
7777
```
7878

79+
### Apply Two Converter Modes
80+
81+
The converter works in **Type** and **Content** modes. You can extract the `ErrorType` or the `ErrorContent` from the `IDataErrorInfo.Error` string:
82+
83+
* **Type** mode drives an implicit `ErrorControl` style that picks the appropriate icon (Critical/Warning/Information).
84+
* **Content** mode feeds a custom tooltip that displays the error message next to the editor.
85+
86+
```xaml
87+
<Window.Resources>
88+
<ResourceDictionary>
89+
<local:ErrorContentConverter x:Key="ErrorContentToErrorTypeConverter" GetValueTag="ErrorType" Separator=";"/>
90+
<local:ErrorContentConverter x:Key="ErrorContentConverter" GetValueTag="ErrorContent" Separator=";"/>
91+
92+
<Style TargetType="{x:Type dxe:ErrorControl}" BasedOn="{StaticResource {x:Type dxe:ErrorControl}}">
93+
<Style.Triggers>
94+
<DataTrigger Binding="{Binding Path=Content.ErrorContent, RelativeSource={RelativeSource Self}, Converter={StaticResource ErrorContentToErrorTypeConverter}}" Value="Critical">
95+
<Setter Property="ContentTemplate" Value="{DynamicResource {dxet:ErrorTypesThemeKeyExtension ResourceKey=Critical}}" />
96+
</DataTrigger>
97+
<DataTrigger Binding="{Binding Path=Content.ErrorContent, RelativeSource={RelativeSource Self}, Converter={StaticResource ErrorContentToErrorTypeConverter}}" Value="Warning">
98+
<Setter Property="ContentTemplate" Value="{DynamicResource {dxet:ErrorTypesThemeKeyExtension ResourceKey=Warning}}" />
99+
</DataTrigger>
100+
<DataTrigger Binding="{Binding Path=Content.ErrorContent, RelativeSource={RelativeSource Self}, Converter={StaticResource ErrorContentToErrorTypeConverter}}" Value="Information">
101+
<Setter Property="ContentTemplate" Value="{DynamicResource {dxet:ErrorTypesThemeKeyExtension ResourceKey=Information}}" />
102+
</DataTrigger>
103+
</Style.Triggers>
104+
</Style>
105+
</ResourceDictionary>
106+
</Window.Resources>
107+
108+
<StackPanel>
109+
<dxe:TextEdit EditValue="{Binding Path=TestString, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}">
110+
<dxe:TextEdit.ErrorToolTipContentTemplate>
111+
<DataTemplate>
112+
<TextBlock Text="{Binding Path=ErrorContent, Converter={StaticResource ErrorContentConverter}}" />
113+
</DataTemplate>
114+
</dxe:TextEdit.ErrorToolTipContentTemplate>
115+
</dxe:TextEdit>
116+
</StackPanel>
117+
```
118+
79119
## Files to Review
80120

81121
* [MainWindow.xaml](./CS/MainWindow.xaml) (VB: [MainWindow.xaml](./VB/MainWindow.xaml))

0 commit comments

Comments
 (0)