问题
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