【发布时间】:2010-06-16 16:02:32
【问题描述】:
我在名为 A 的 DependencyProperty 中添加了一个 ValidateValueCallback。现在在验证回调中,应将 A 与名为 B 的 DependencyProperty 的值进行比较。但是如何在 static 中访问 B 的值ValidateValueCallback 方法 validateValue(object value)?感谢您的任何提示!
示例代码:
class ValidateTest : DependencyObject
{
public static DependencyProperty AProperty = DependencyProperty.Register("A", typeof(double), typeof(ValidateTest), new PropertyMetadata(), validateValue);
public static DependencyProperty BProperty = DependencyProperty.Register("B", typeof(double), typeof(ValidateTest));
static bool validateValue(object value)
{
// Given value shall be greater than 0 and smaller than B - but how to access the value of B?
return (double)value > 0 && value <= /* how to access the value of B ? */
}
}
【问题讨论】:
标签: c# wpf validation dependency-properties