wpf – XAML:请参阅普通XAML中的StaticResource? (没有标记扩
发布时间:2020-12-17 07:19:23 所属栏目:百科 来源:网络整理
导读:我正在设置一系列文本框的验证规则.我宁愿不为每个TextBox创建一个新的自定义验证规则实例…… Window.Resources my:IsIntegerRule x:Key="IsIntegerRule"//Window.Resources......TextBox TextBox.Text Binding XPath="@num" UpdateSourceTrigger="Property
我正在设置一系列文本框的验证规则.我宁愿不为每个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> 有人可以帮忙吗? 解决方法
您可以使用常规属性元素语法进行标记扩展.见
Markup Extensions and WPF XAML.它看起来像这样:
<Binding.ValidationRules> <StaticResource ResourceKey="IsIntegerRule"/> </Binding.ValidationRules> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |