Mat*_* H. 4 vb.net data-binding validation wpf xaml
我正在设置一系列文本框的验证规则.我宁愿不为每个TextBox创建一个新的自定义验证规则实例......
<Window.Resources>
<my:IsIntegerRule x:Key="IsIntegerRule"/>
</Window.Resources>
...
...
<TextBox>
<TextBox.Text>
<Binding XPath="@num" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
<Binding.ValidationRules>
<-- WHAT IS THE EQUIVALENT OF WRITING: {StaticResource IsIntegerRule} here -->
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
您可以使用常规属性元素语法进行标记扩展.请参阅标记扩展和WPF XAML.它看起来像这样:
<Binding.ValidationRules>
<StaticResource ResourceKey="IsIntegerRule"/>
</Binding.ValidationRules>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3068 次 |
| 最近记录: |