【问题标题】:How to fix this binding error in WPF?如何在 WPF 中修复此绑定错误?
【发布时间】:2013-10-16 10:46:21
【问题描述】:

我有一个带有属性的视图模型

public string ErrorMessage

在我的 XAML 中有

 <TextBox Grid.Column="7" Text="{Binding Path=ErrorMesssage}"/>

我收到此错误消息

System.Windows.Data Error: 40 : 
BindingExpression path error: 
'ErrorMesssage' property not found on 'object' 
''MoineauPumpCorrectionViewModel'
 (HashCode=27349565)'. BindingExpression:Path=ErrorMesssage; 
DataItem='MoineauPumpCorrectionViewModel' (HashCode=27349565);
 target element is 'TextBox' (Name=''); target property is 'Text' (type 'String')

现在的问题是这样的。我加载 snoop 以查看 TextBox 的数据上下文

很明显,datacontext 确实是我正确的视图模型,并且它具有 ErrorMessage 属性,在这种情况下,正如我所料,它读取为 cannot be empty。那么我在这里做错了什么?

【问题讨论】:

    标签: wpf xaml binding


    【解决方案1】:

    抱歉,你的 ErrorMessage 拼错了。

    去掉多余的's' :D

    而不是这个

    <TextBox Grid.Column="7" Text="{Binding Path=ErrorMesssage}"/>
    

    试试这个

    <TextBox Grid.Column="7" Text="{Binding Path=ErrorMessage}"/>
    

    【讨论】:

    • 该死的。睡眠不足。连续3个sss。 :)
    • @bradgonesurfing 显然是完全错误的字母!你需要更多 Zs。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-18
    • 1970-01-01
    • 2021-10-01
    • 2015-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多