如何通知视图模型的所有属性已更改 [英] How to notify all properties of the view model has changed

查看:67
本文介绍了如何通知视图模型的所有属性已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MVVM模式中,如何通知视图模型的所有属性已更改?我不想调用所有属性的所有notifypropertychanged事件.

In MVVM pattern, how to notify all properties of the view model has changed? I don' t want to call all notifypropertychanged event of all properties.

我有一个实体类,并且在视图模型中,我将该实体的所有公共字段都写为公共属性.我想重新绑定新实体,只写一行代码以通知所有属性都已更改?

I have an entity class and in view model I wrote all of the public fields of the entity as public properties. I want to rebind new entity and just write a single line of code to notify that all properties has changed?

感谢您的帮助.

推荐答案

只需使用空字符串作为属性名称引发PropertyChanged事件:

Just raise the PropertyChanged event with an empty string as the property name :

OnPropertyChanged(String.Empty);

这篇关于如何通知视图模型的所有属性已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆