使用ElementName路径进行绑定验证错误

时间:2012-05-18 07:04:18

标签: silverlight

TextBox1的:

<TextBox x:Name="TextBox1" Text="{Binding IdNumber, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" />

TextBox2中:

<TextBox x:Name="TextBox2" Text="{Binding Text,ElementName=TextBox1, Mode=TwoWay}" />

目前:使用上面的代码文本绑定工作正常,但错误验证无效。 期望:如果假设,TextBox1中发生的任何验证错误都应反映在TextBox2中。

1 个答案:

答案 0 :(得分:0)

根据属性触发验证状态,而不是值。对于TextBox2,与IdNumber属性中存在错误无关,因为TextBox1的Text属性没有任何错误。

在TextBox2中显示IdNumber错误的唯一方法是绑定到IdNumber属性。 绑定到IdNumber属性也将导致TextBox1和TextBox2显示相同的文本

相关问题