Assuming you are trying to link a command in the Meeting class from DataGrid:
You can use RelativeSourcein your binding to go to DataContextwhich is interesting to you. Your markup would look something like this:
<Grid DataContext="...">
...
<DataGrid ...>
...
<Button Content="Click Me!"
Command="{Binding Path="DataContext.RemovePersonCommand"
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Grid}}}"
CommandParameter="{Binding}"/>
...
</DataGrid>
...
</Grid>
You can also use ElementNameto bind to the parent object, which is of interest to you DataContext, if you are dealing with a lot of nesting, but it RelativeSourcewill be too complicated.
source
share