Gur*_*ruC 8 validation wpf templates
我有一个绑定到某个属性的TextBox.我已经实现了IDataErrorInfo来执行验证.最近我在网上看到了一些控制,显示出像红色三角形一样的错误.我附上了以下示例:

我知道我必须编写错误模板,以便在发生错误时显示它.当用户悬停红色三角形时,它将在工具提示中显示错误消息.如何显示错误文本框,就像我上传的文本框一样.如何在错误模板中获取红色三角形?
Fre*_*lad 14
这是一个看起来像这样的例子

像它一样使用它
<TextBox Validation.ErrorTemplate="{StaticResource topRightCornerErrorTemplate}"
.../>
Run Code Online (Sandbox Code Playgroud)
ErrorTemplate
<ControlTemplate x:Key="topRightCornerErrorTemplate">
<Grid>
<Polygon Points="40,20 40,0 0,0"
Stroke="Black"
StrokeThickness="1"
Fill="Red"
HorizontalAlignment="Right"
VerticalAlignment="Top"
ToolTip="{Binding ElementName=adorner,
Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"/>
<AdornedElementPlaceholder x:Name="adorner"/>
</Grid>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4854 次 |
| 最近记录: |