gpt4 book ai didi

c# - 系统.Windows.数据错误 : 40 : BindingExpression path error: property not found on object

转载 作者:行者123 更新时间:2023-11-30 13:57:56 25 4
gpt4 key购买 nike

很抱歉要添加到大量类似的绑定(bind)错误问题列表中,但经过数小时的搜索后,我找不到适合我的解决方案!

我正在尝试在 WPF 中测试 ViewModel,但 ICommand 按钮代码导致了标准绑定(bind)错误:

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 中)是:

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>

谁能告诉我我做错了什么?在这一点上,我只是迫切需要一些新的见解。

提前感谢您抽出时间!

最佳答案

您使用了绑定(bind)路径 CheckforNewHubs 但它应该是 CheckForNewHubs

关于c# - 系统.Windows.数据错误 : 40 : BindingExpression path error: property not found on object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19228677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com