【问题标题】:PropertyChanged for all Properties: Message=Property not found所有属性的 PropertyChanged:消息=找不到属性
【发布时间】:2011-04-03 01:27:26
【问题描述】:

我想一次性为我的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 检查所有属性名称。

我能做什么?

【问题讨论】:

    标签: mvvm-light


    【解决方案1】:

    您可以file a bug report,与此同时,您自己也可以change MVVM Light

    【讨论】:

      【解决方案2】:

      如果您查看源代码,您会发现只有在编译为 DEBUG 时才会引发此异常。如果您编译为 RELEASE,您将不会再出现这种行为。

      就像 Kent 所说,我将源代码更改为执行 Debug.Writeline 而不是抛出异常。我不喜欢默认行为,尤其是因为我通常会从子 ViewModel 列表中将 PropertyChanged 重新提升为父 ViewModel。

      【讨论】:

        猜你喜欢
        • 2010-12-24
        • 2016-08-01
        • 1970-01-01
        • 2014-07-29
        • 1970-01-01
        • 2010-10-14
        • 1970-01-01
        • 2012-05-29
        • 1970-01-01
        相关资源
        最近更新 更多