gpt4 book ai didi

silverlight - 在模型列表上手动调用 PropertyChanged

转载 作者:行者123 更新时间:2023-12-03 10:55:37 31 4
gpt4 key购买 nike

在我的 ViewModel 中,我有一个属性,它是模型列表:

private List<LocationModel> _locations = null;
public List<LocationModel> Locations
{
get
{
return this._locations;
}
set
{
this._locations = value;
RaisePropertyChanged("Locations");
}
}

但是 LocationModel类没有实现 INotifyPropertyChanged ,所以当我更新列表中某个项目的属性时,UI 不会更新。我试图通过在更改列表项后手动引发事件来实现这一点,但这不起作用。有人可以解释为什么这种方法不起作用吗?

提前致谢。

最佳答案

INotifyPropertyChanged仅适用于实现该接口(interface)的对象的实例属性。不是实现接口(interface)的属性的属性。 LocationModel需要执行INotifyPropertyChanged如果你想让这个工作。如果您没有 LocationModel 的源代码,或者由于任何原因无法更改它,则需要将所有要对其使用react的属性包装在实现 INotifyPropertyChanged 的包装类中。 .您可以使用 DynamicProxy 动态换行(死链接)DynamicProxy (cached) .

关于silverlight - 在模型列表上手动调用 PropertyChanged,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11248894/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com