0
我使用文本块控件来显示如下错误。Validation.HasError无法正常工作
<TextBlock Text="{Binding ElementName=txtPassword, Path=(Validation.Errors)[0].ErrorContent}"
Visibility="{Binding ElementName=txtPassword,Path=Validation.HasError,Converter={StaticResource BoolToVisibilityConverter}}"
Foreground="Red" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Left" />
绑定文本属性工作正常,但绑定不能使用可见性属性。在输出窗口中出现错误。
BindingExpression path error:在'object''''PasswordBox'(Name ='txtPassword')'找不到'验证'属性。 BindingExpression:路径= Validation.HasError; DataItem ='PasswordBox'(Name ='txtPassword');目标元素是'TextBlock'(Name ='');目标属性是'可见性'(类型'可见性')
bool? a = txtLoging.GetValue(Validation.HasErrorProperty)为bool? ;这段代码在后面的代码中工作。 – Rudra
您的xaml适合我,请使用代码隐藏更新您的问题 – lena