我想一次性为我的 ViewModel
的所有 20 个属性提出 PropertyChanged
并获得解决方案:
RaisePropertyChanged(String.Empty)
参见:C#/WPF: PropertyChanged for all Properties in ViewModel?
由于我使用 MVVM Light 的 GalaSoft.MvvmLight.ViewModelBase.RaisePropertyChanged
,因此出现运行时错误:
Message=Property not found
ParamName=""
Source=GalaSoft.MvvmLight.WPF4
这是因为 MVVM Light 检查所有属性名称。
我能做什么?
最佳答案
如果您查看源代码,您会发现只有当您编译为 DEBUG 时才会引发此异常。如果您编译为 RELEASE,您将不会再出现此行为。
就像 Kent 所说,我更改了源代码以执行 Debug.Writeline,而不是抛出异常。我不喜欢默认行为,特别是因为我通常会从子 ViewModel 列表中将 PropertyChanged 重新提升为父 ViewModel。
关于mvvm-light - 所有属性的 PropertyChanged : Message=Property not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3554831/