System.Windows.Data错误:40:BindingExpression路径错误:属性对象上未找到 [英] System.Windows.Data Error: 40 : BindingExpression path error: property not found on object
问题描述
许多歉意添加到类似的绑定错误问题,大量的名单在那里,但搜索我不能找到一个解决方案,为我工作了几个小时之后!
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!
我想在WPF来测试视图模型,但ICommand的按钮代码导致该标准绑定错误:
I am trying to test a ViewModel in WPF, but the ICommand Button code is causing the standard binding error:
System.Windows。数据错误:40:BindingExpression路径错误:'CheckforNewHubs'属性不是'对象'''HubManagerViewModel'(的hashCode = 13328197)找到。 BindingExpression:路径= CheckforNewHubs;的DataItem ='HubManagerViewModel'(的hashCode = 13328197);目标元素是'按钮'(名称='CheckForNewHubsButton');目标属性命令(类型'的ICommand')
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')
我的命令(在HubManagerViewModel)是:
my command (in HubManagerViewModel) is:
public ICommand CheckForNewHubs
{
get{
return new RelayCommand(this.CheckForNewHubsExecute, this.CanSendHubManagerCommands);
}
set { }
}
和我的DataContext是在XAML网发起的为:
and my DataContext is initiated in an XAML grid as:
<Grid.DataContext>
<ViewModels:HubManagerViewModel/>
</Grid.DataContext>
我曾尝试明确设置按钮的DataContext的是这样的:
I have tried explicitly setting the dataContext of the button like this:
<Button.DataContext>
<ViewModels:HubManagerViewModel/>
</Button.DataContext>
但无济于事:(
but to no avail :(
谁能告诉我什么,我做错了吗?在这一点上,我只是绝望了一些新的见解。
Can anyone tell me what I'm doing wrong? At this point I'm just desperate for some new insight.
感谢您的时间提前!
推荐答案
您已经使用绑定路径 CheckforNewHubs
,但它应该是 CheckForNewHubs
。
You have used Binding Path CheckforNewHubs
but it should be CheckForNewHubs
.
这篇关于System.Windows.Data错误:40:BindingExpression路径错误:属性对象上未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!