It looks like you are setting the DataContext Grid to the Data property of your ViewModel (or object). If the object that provides the Data property does not provide the SaveData command, you will have a problem that you are describing. Remember that a DataContext is inherited from the parent.
If you require the DataContext to be set this way and still require the button to reference the parent DataContext, one option would be to use a RelativeSource to specify an element that has the ViewModel as the DataContext.
In WPF, you also have the option to make these commands static and use the {x: Static} markup extension to achieve this.
Hope this helps.
EDIT: Here's an example if your <Grid> contained in <UserControl> .
<Button Command="{Binding Path=DataContext.SaveData, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" ... />
Also, I donβt know what your full Xaml looks like, but I suspect it can be greatly simplified by removing the DataContext in the Grid and Binding Data on the ItemsControl (or what you use to display a list of objects).
source share