我有一个对象public class Order : INotifyPropertyChanged
{
public double TotalAmount { get; set; }
public ObservableCollection<Line> Lines { get; set; }
}public class Line : INotifyPropertyChanged
{
public Amount { get; set; }
}
Order.TotalAmount 是 Lines集合的子对象属性Amount之和。
我想实现这样的一个功能,Lines集合对象的修改、增、删,Order.TotalAmount会同步。
我现在使用Lines.CollectionChanged事件实现了增、删的同步,但是不知道如何让修改Lines集合子对象的Amount值时同步。
{
public double TotalAmount { get; set; }
public ObservableCollection<Line> Lines { get; set; }
}public class Line : INotifyPropertyChanged
{
public Amount { get; set; }
}
Order.TotalAmount 是 Lines集合的子对象属性Amount之和。
我想实现这样的一个功能,Lines集合对象的修改、增、删,Order.TotalAmount会同步。
我现在使用Lines.CollectionChanged事件实现了增、删的同步,但是不知道如何让修改Lines集合子对象的Amount值时同步。
解决方案 »
- 不可理喻的错误,那位高手能帮小弟看看,不胜感激!
- c# treeview 选中某项后,焦点移开后,比如焦点到文本框里了,此时发现treeview刚才选中的某项的选中状态消失了。
- SqlDataAdapter分页
- 一段上传代码出了问题,高过10MB文件就不调用button方法!(内附上传代码)
- 如何在服务器代码中指定客户端页面的onload事件?
- 求学:作为参数的控件
- 请问做paypal的加密参数时,为什么会出现The signer's certificate is not valid for signing?
- 如何得到枚举类型的基础类型?
- 有关将文字拖放到TextBox中
- txt = (TextBox)cart.Items[i].FindControl(ID_TXT);怎么理解?
- 【oj每周推荐】谈谈.Net里的引用
- sql链接查询问题??急等。。。
{
private string firstNameValue;
public string FirstName{
get { return firstNameValue; }
set
{
firstNameValue=value;
NotifyPropertyChanged("FirstName");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
通知事件我省略了,没有写出来。
问题在于修改Lines对象时同步显示按2楼给出的方法其实是个只读属性,但我这里不是只读属性,是类似3楼的类。