Reputation: 3105
I'm using FindAncestor and AncestorLevel=3 to reach to the top level tag which should have the viewModel relay command, but it doesnt work. Any suggestions if I am doing it wrong or a way to debug this scenario?
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding name}" Cursor="Hand"
Foreground="Blue" TextDecorations="Underline">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<cmd:EventToCommand Command="{Binding NameClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=Grid, AncestorLevel=3}}"
MustToggleIsEnabled="True" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
Upvotes: 2
Views: 1156
Reputation: 84684
It seems like you're binding the Command to a property called NameClickCommand on a Grid. Grid doesn't have this property, so try to change it to
Command="{Binding Path=DataContext.NameClickCommand...
if the NameClickCommand is in the DataContext of the Grid
Upvotes: 3
Reputation: 57979
You're looking for the 3rd Grid
up the hierarchy -- is that what you want?
Note that Grid
does not include DataGrid
.
Upvotes: 1