PropertyChanged for all Properties: Message=Property not found

淺唱寂寞╮ 提交于 2019-12-11 06:57:53

问题


I want to raise PropertyChanged for all 20 Properties of my ViewModel in once and get the solution:

RaisePropertyChanged(String.Empty)

see: C#/WPF: PropertyChanged for all Properties in ViewModel?

Since I use GalaSoft.MvvmLight.ViewModelBase.RaisePropertyChanged of MVVM Light, I get the runtime error:

   Message=Property not found
   ParamName=""
   Source=GalaSoft.MvvmLight.WPF4

This is because MVVM Light check all Property-Names.

What can I do?


回答1:


If you look at the source, you'll see that this exception is only raised when you're compiling as DEBUG. If you compile as RELEASE you won't get this behavior anymore.

Like Kent said, I changed the source to do a Debug.Writeline instead of throwing an exception. I don't like the default behavior, especially since I will commonly re-raise PropertyChanged to a parent ViewModel from a list of child ViewModels.




回答2:


You could file a bug report and, in the meantime, change MVVM Light yourself.



来源:https://stackoverflow.com/questions/3554831/propertychanged-for-all-properties-message-property-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!