[英]the namespace prefix “utilities” is not defined
I am fairly new to WPFs... I was trying to bind a validation to a text box in WPF. 我对WPF相当陌生...我试图将验证绑定到WPF中的文本框。
Here is my text box in the xaml: 这是我在xaml中的文本框:
<TextBox>
<TextBox.Text>
<Binding Source="{x:Static r:Settings.Default}" Path="ServerIP" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<utilities:PingValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Here is my validation class: 这是我的验证类:
public class PingValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
...
if (ipCorrect) return new ValidationResult(true, null);
else return new ValidationResult(false, "It's not an IP");
}
}
With this I have the following error: 有了这个我有以下错误:
Error The namespace prefix "utilities" is not defined.
错误未定义名称空间前缀“实用程序”。
Anyone knows why? 有人知道为什么吗?
It is not defined because you did not define it. 未定义,因为您没有定义它。 Look at the top of your XAML file, all the stuff like
xmlns:foobar="clr-namespace:Foo.Bar"
. 查看XAML文件的顶部,所有类似
xmlns:foobar="clr-namespace:Foo.Bar"
。 You need to define it there. 您需要在那里定义它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.