PopUpMenu on DataGrid columns

Feb 23, 2012 at 12:34 PM


Becouse addTrigger in CodeBehind or e.g RightClickElements need in parameter UIElement that it can't be easy to set popUpMenu for datagrid.columns or datagrid.column[x].

Is there any chance to make this to work with sl4popupmenu?

Best regards,


Feb 24, 2012 at 4:11 PM
Edited Feb 24, 2012 at 4:13 PM

You can add a tag, say 'hasMenu', to the datagrid columns or each cell within it and then use RightCickElements = '.hasMenu' to associate the menu with them at startup. Note the use of the prefix '.' when you intend to target the tag property.

If you're ok with using code behind then the AddTrigger method should get you going.

However if you need more control you can also use the GetClickedElements<T> function(see Demo1) to determine which control was clicked and cancel the opening event using the IsOpenCancelled from there.