将参数传递给验证例程 [英] Passing a parameter to a validation routine

查看:55
本文介绍了将参数传递给验证例程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有ComboBox和TextBox的wpf窗口(以及许多与此无关的其他内容),并且我正在尝试为Textbox编写验证例程.
在我的XAML中,我有:

I have a wpf window with a ComboBox and a TextBox (and lots of other stuff not relevant here) and I am trying to write a validation routine for the Textbox.
In my XAML I have:

<TextBox>
    <Binding
	    Path="Charge"
		UpdateSourceTrigger="Explicit">
		<Binding.ValidationRules>
		    <abc:VT />
		</Binding.ValidationRules>
	</Binding>
</TextBox>

其中VT是我的验证例程,而"abc"是我的验证例程是一个程序集,其中包含项目中使用的所有验证例程,并且在我的项目参考中.
 
我遇到的问题是,VT需要知道ComboBox的SelectedValue才能知道如何执行验证.如何将这些数据导入VT?

where VT is my validation routine and "abc" is an assembly that contains all the validation routines used in the project and is in my Project References.
 
The problem I'm having is that VT needs to know the SelectedValue of the ComboBox in order to know how to perform the validation.  How do I get that data into VT?

推荐答案

我有一个带有ComboBox和TextBox的wpf窗口(以及许多此处不相关的其他内容),并且我正在尝试为Textbox编写验证例程.

I have a wpf window with a ComboBox and a TextBox (and lots of other stuff not relevant here) and I am trying to write a validation routine for the Textbox.

有关WPF的问题应在中提出 Windows Presentation 基金会(WPF)

Questions relating to WPF should be asked at the Windows Presentation  Foundation (WPF) forum.


这篇关于将参数传递给验证例程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆