Silverlight InotifyProperty为属性的属性更改
我认为描述这个问题最好的方法是用一个非常简单的例子 假设你有两个班。称他们为Silverlight InotifyProperty为属性的属性更改,silverlight,wcf,inotifypropertychanged,Silverlight,Wcf,Inotifypropertychanged,我认为描述这个问题最好的方法是用一个非常简单的例子 假设你有两个班。称他们为Train和Status 在Train的DomainService中,有一行代码如下: [Include] public Status { get; set;} 状态有两个属性:名称和显示颜色 现在,将Train对象的ObservableCollection绑定到DataGrid 将状态的可观测集合绑定到另一个数据网格 然后更新一个状态对象 是否有任何方法可以使此更改自动反映在持有列车对象的数据网格中? 谢谢你 我认为
Train
和Status
在Train
的DomainService
中,有一行代码如下:
[Include]
public Status { get; set;}
状态
有两个属性:名称
和显示颜色
Train
对象的ObservableCollection
绑定到DataGrid
状态的可观测集合
绑定到另一个数据网格
状态
对象李>
列车
对象的数据网格
中?谢谢你 我认为这就是您想要的(假设服务和状态都实现INotifyPropertyChanged):
private Status _status;
[Include]
public Status Status
{
get { return _status; }
set
{
if (_status == value) return;
if (_status != null)
_status.PropertyChanged -= NotifyStatusChanged;
_status = value;
// Whatever your implementation of INotifyPropertyChanged looks like.
RaiseNotifyPropertyChanged(()=> Status);
if (_status != null)
_status.PropertyChanged += NotifyStatusChanged;
}
}
private void NotifyStatusChanged(object o, EventArgs e)
{
// Whatever your implementation of INotifyPropertyChanged looks like.
RaiseNotifyPropertyChanged(()=> Status);
}