4

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!

Yael
  • 1,566
  • 3
  • 18
  • 25
Tim
  • 63
  • 1
  • 4

1 Answers1

8

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

LPL
  • 16,827
  • 6
  • 51
  • 95