I have a context menu that is defined as a resource and bound to the SelectedItem in a DataGrid, using a converter to get the display name of the current item, as in "Edit " or "Edit "
It works fine for the first selected item, but doesn't call the converter on the second (I have a break point in it that only gets hit on the first pass). BUT if I invoke the bound command on the second pass, it invokes on the newly selected instance as it should.
I use this technique with other ItemsControls and I can't spot anything wrong. Any ideas?
Cheers,
Berryl
Resource & binding
<ContextMenu x:Key="ProjectActivityContextMenu" x:Shared="true">
...
<MenuItem Header="{Binding SelectedProjectActivity, Converter={StaticResource DeleteProjectConv}}" Command="{Binding DeleteCommand}" />
</ContextMenu>
Wiring
<DataGrid ...
SelectedItem="{Binding SelectedProjectActivity}"
IsSynchronizedWithCurrentItem="True"
ContextMenu="{DynamicResource ProjectActivityContextMenu}"
>
UPDATE
This also happens if I declare it as part of the grid, like:
<DataGrid.ContextMenu>
<ContextMenu >
....
<MenuItem Header="{Binding SelectedProjectActivity, Converter={StaticResource DeleteProjectConv}}" Command="{Binding DeleteCommand}" />
</ContextMenu>
</DataGrid.ContextMenu>