System.Windows.Data错误:40:BindingExpression路径错误:对象上找不到属性 [英] System.Windows.Data Error: 40 : BindingExpression path error: property not found on object

查看:1992
本文介绍了System.Windows.Data错误:40:BindingExpression路径错误:对象上找不到属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多道歉,添加到类似的绑定错误问题的大量列表中,但在搜索几个小时后,我找不到可以为我工作的解决方案。



我试图在WPF中测试一个ViewModel,但ICommand Button代码导致标准的绑定错误:


System.Windows。数据错误:40:BindingExpression路径错误:'在'Object'''HubManagerViewModel'(HashCode = 13328197)'中找不到'CheckforNewHubs'属性。 BindingExpression:Path = CheckforNewHubs; DataItem ='HubManagerViewModel'(HashCode = 13328197);目标元素是Button(Name ='CheckForNewHubsButton'); target属性为'Command'(类型'ICommand')


我的命令(在HubManagerViewModel中)是:

  public ICommand CheckForNewHubs 
{
get
{
return new RelayCommand(this.CheckForNewHubsExecute,this.CanSendHubManagerCommands );
}
set {}
}

我的DataContext是在XAML网格中启动:

 < Grid.DataContext> 
< ViewModels:HubManagerViewModel />
< /Grid.DataContext>

我已经尝试显式地设置按钮的dataContext:

 < Button.DataContext> 
< ViewModels:HubManagerViewModel />
< /Button.DataContext>

任何人都可以告诉我我在做错什么?在这一点上,我只是绝望的一些新的见解。



感谢您提前的时间!

解决方案

您已使用Binding Path CheckforNewHubs ,但应该是 CheckForNewHubs p>

Many apologies to add to the massive list of similar binding error questions out there, but after hours of searching I can't find a solution that will work for me!

I am trying to test a ViewModel in WPF, but the ICommand Button code is causing the standard binding error:

System.Windows.Data Error: 40 : BindingExpression path error: 'CheckforNewHubs' property not found on 'object' ''HubManagerViewModel' (HashCode=13328197)'. BindingExpression:Path=CheckforNewHubs; DataItem='HubManagerViewModel' (HashCode=13328197); target element is 'Button' (Name='CheckForNewHubsButton'); target property is 'Command' (type 'ICommand')

my command (in HubManagerViewModel) is:

public ICommand CheckForNewHubs
{
    get
    {
        return new RelayCommand(this.CheckForNewHubsExecute, this.CanSendHubManagerCommands);
    }
    set { }
}

and my DataContext is initiated in an XAML grid as:

<Grid.DataContext>
    <ViewModels:HubManagerViewModel/>
</Grid.DataContext>

I have tried explicitly setting the dataContext of the button like this:

<Button.DataContext>
    <ViewModels:HubManagerViewModel/>
</Button.DataContext>

Can anyone tell me what I'm doing wrong? At this point I'm just desperate for some new insight.

Thanks for your time in advance!

解决方案

You have used Binding Path CheckforNewHubs but it should be CheckForNewHubs.

这篇关于System.Windows.Data错误:40:BindingExpression路径错误:对象上找不到属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆