【发布时间】:2011-06-08 12:35:11
【问题描述】:
考虑以下场景:
<TextBox Text="{Binding Price}"/>
这是价格属性
public Decimal Price
{
get
{
return _Price;
}
set
{
if (_Price != value)
{
_Price = value;
OnPropertyChanged("Price");
}
}
}
此方法检查我的财产
private string validateGlassPrice()
{
if (GlassPrice <= 0)
{
return "price can't be 0 nor a minus value ";
}
else
{
return String.Empty;
}
}
此方法检查我的属性是否为 0 或更小 - 一个负值 - 现在我需要检查它是 null 还是空,问题是 Decimal 不接受可为空的值,有什么解决方法吗?
提前致谢
【问题讨论】:
标签: .net wpf data-binding mvvm