我有下面的文本框,它们在视图模型中的属性发生了变化。当我插入Binding.ValidationRules并插入一些错误的值时,它不会触发propertychanged _ trigger事件,我不知道为什么。有什么帮助吗?
<TextBox Name="RiskCode" HorizontalAlignment="Left" Margin="101.923,8,0,81" TextWrapping="Wrap" Width="56.077" MaxLength="6" Validation.ErrorTemplate="{StaticResource validationTemplate}"
Style="{StaticResource textBoxInError}">
<TextBox.Text>
<Binding Path="RiskCode" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<vm:RiskCodeValidation/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>发布于 2012-06-12 02:43:48
使用ValidationStep。
http://msdn.microsoft.com/en-us/library/system.windows.controls.validationrule.validationstep.aspx
RawProposedValue -在任何转换之前运行ValidationRule occurs.ConvertedProposedValue -在值为converted.UpdatedValue之后运行ValidationRule -在源为updated.CommittedValue之后运行ValidationRule -在值提交到源之后运行ValidationRule。默认情况下,它是RawProposedValue,它阻止绑定到源代码-这就是您的困惑所在。请使用不同的选项:
<Binding.ValidationRules>
<vm:RiskCodeValidation ValidationStep="UpdatedValue" />
</Binding.ValidationRules>https://stackoverflow.com/questions/10984763
复制相似问题