I have usercontrol where I am trying to set the context as below
<UserControl.DataContext>
<Binding ElementName="dataGrid" Path="MyViewModel">
</Binding>
</UserControl.DataContext>
Here dataGrid is a child DataGrid control and MyViewModel is my ViewModel class. Currently its giving following error while runtime:
Cannot find source for binding with reference 'ElementName=dataGrid'. BindingExpression:Path=MyViewModel; DataItem=null; target element is 'UserControl1' (Name=''); target property is 'DataContext' (type 'Object')
Can anyone please help what is the problem here?