I want to use the CommandParameter attribute in the context menu associated with the DataTemplate. The commandParameter parameter must contain a reference to the object that initiated the data template, as shown in the code example below. I tried to use "{Binding Path = this}", but this does not work because "this" is not a property. The command fires, but I cannot get the correct parameter. Does anyone have an idea on how to do this?
Note. I deleted Command = "{Binding DeleteSelectedMeetingCommand}", replacing it with a reference to the view locator and initiating the command.
<DataTemplate DataType="{x:Type Models:MeetingDbEntry}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Path=HostTeam}"/>
<TextBlock Grid.Column="1" Text="{Binding Path=GuestTeam}"/>
<TextBlock Grid.Column="2" Text="{Binding Path=Result}"/>
<Grid.ContextMenu>
<ContextMenu Name="MeetingMenu">
<MenuItem Header="Delete"
Command="{Binding
Source={StaticResource Locator},
Path=Main.DeleteSelectedMeetingCommand}"
CommandParameter="{Binding Path=this}"/>
</ContextMenu>
</Grid.ContextMenu>
</Grid>
</DataTemplate>
Thank,