Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

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!

like image 699
Tim Avatar asked Sep 17 '25 20:09

Tim


1 Answers

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

like image 171
LPL Avatar answered Sep 20 '25 11:09

LPL