mvvm-light - 所有属性的 PropertyChanged : Message=Property not found

标签 mvvm-light

我想一次性为我的 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/

相关文章:

windows-phone-8 - 内存中 View 和 View 模型的多个实例

silverlight - 如何在 Mvvm Light 中使用 ViewModelLocator

wpf - WPF中的单元测试路由事件

visual-studio - 如何打开/加载 vsix 文件

c# - 如何使用 MVVM 在 Windows Phone 8.1 中使用 listpickerflyout

silverlight - 使用 MVVM 和 RIA 服务的不同绑定(bind)方法的优缺点

c# - 在 VS2012 中使用 EventToCommand 时出现 XAML "Invalid Markup"错误

c# - MVVM 模式,我不明白我应该如何编写 "Detail"ViewModel

c# - 如何在 try catch 语句中包装 MVVM Light ViewModel?

windows-phone-7 - 难以解决性能问题