我有3个文本框,第一个是持续时间,第二个是金额,第三个是只是持续时间*金额的总和。我试图用NotifyOfPropertyChange实现OnPropertyChange INSTEAD。我想知道我是否可以获得帮助,知道为什么它没有更新。NotifyOfPropertyChange Not Updating
public int? SebDuration
{
get
{
return _seb.SEBDuration;
}
set
{
_seb.SEBDuration = value;
NotifyOfPropertyChange("SebDuration");
NotifyOfPropertyChange("SebTotal");
}
}
public decimal? SebAmountPer
{
get
{
return _seb.SEBAmountPer;
}
set
{
_seb.SEBAmountPer = value;
NotifyOfPropertyChange("SebAmountPer");
NotifyOfPropertyChange("SebTotal");
}
}
public decimal? SebTotal
{
get
{
if (_seb.SEBTotal.HasValue)
{
return _seb.SEBTotal;
}
if (SebAmountPer.HasValue && SebDuration.HasValue)
{
return SebAmountPer.Value * SebDuration.Value;
}
return null;
}
set
{
if (_seb.SEBTotal != value)
{
_seb.SEBTotal = value;
NotifyOfPropertyChange("SebTotal");
}
}
}
如果我更换OnPropertyChanged每个NotifyOfPropertyChange,它会工作。
这是什么NotifyOfPropertyChange方法?你自己创造了吗?这不是一个标准的方法,无论如何,所以我们不能在没有看到它的代码的情况下帮助你... –
@ThomasLevesque它可能是Caliburn Micro。不是标准的WPF,也不是自定义的。 – BradleyDotNET
@BradleyDotNET,很高兴知道,谢谢 –