DataGridRow ContextMenu CommandParameter

Dec 29, 2009 at 12:11 PM

I have attached a contextmenu to DataGridRow via RowStyle of the datagrid. I am selecting multiple rows in extened selection mode. After selecting rows I am right clicking to show up the context menu.Context menu has command and command parameter binding. SelectedItems of datagrid is passed as command parameter.(CommandParameter="{Binding Path=SelectedItems,Converter={StaticResource itemsSelectedToRulesetListItemConverter} , RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type my:DataGrid}}}")


*Command parameter convertion i.e. selected I items to my source object convertion (IConvert) is done only once. If I repeat the selections and contextmenu selection but no new convertions occured. Always the first selected items are provided to command handler.

*I tried to get selectedItems of datagrid in the command handler but always it has o items in it. I think openning the context menu and making the selection resets selecteditems

how can I achieve this binding?