Hi,
Is there any direct way of creating context menu on Silverlight XamGrid, one way i found out is by extending as shown on
http://es.infragistics.com/community/blogs/devin_rader/archive/2011/04/15/extending-xamgrid-with-a-right-click-context-menu.aspx
But apart from this is there any other way of achieving this, without extending.
-Abhi
Hello Abhijeet,
I have been looking into your post and I am not completely sure what you mean by “direct way of creating context menu”. If you want just to add context menu and add event hadlers for its items, you could use the ContextMenuService to add the menu items and handle there click events.
<ig:ContextMenuService.Manager>
<ig:ContextMenuManager ModifierKeys="None">
<ig:ContextMenuManager.ContextMenu>
<ig:XamContextMenu>
<ig:XamMenuItem Header="Item 1" Click="XamMenuItem_Click"/>
<ig:XamMenuItem Header="Item 2" Click="XamMenuItem_Click_1"/>
<ig:XamMenuItem Header="Item 3" Click="XamMenuItem_Click_2"/>
</ig:XamContextMenu>
</ig:ContextMenuManager.ContextMenu>
</ig:ContextMenuManager>
</ig:ContextMenuService.Manager>
Please let me know if this helps you or provide me some more details of what you are trying to achieve. Thank you.
I want the context menu to be available on xamgrid.
How can i attach the above context menu to XamGrid.
Hello,
Thank you for posting!
Have you tried checking if the element which is being clicked is a DataRow?
Row row = (from x in e.GetClickedElements<CellsPanel>()
select x.Row).FirstOrDefault() as Row;
CellControl cell = e.GetClickedElements<CellControl>().FirstOrDefault();
if (cell != null && cell.Column is FillerColumn)
e.Cancel = true;
//Discard displaying the context menu when not clicking on data rows:
if (row == null || row.RowType != RowType.DataRow)
{
}
This approach is used in the XamGridAddContextMenu_modified.zip sample project which I have attached in one of my previous posts.
Please feel free to let me know if this helps you in resolving your issue.
I made context menu to available on left click. After moving context menu from right to left click, menu is coming on header of xamgrid column and also on pager column. how to disable on those items ?
Thank you for your feedback. I am glad that you resolved your issue and I believe that this will be helpful for other community members.
Its working,
Thanks,
Abhijeet
I am just checking if my last reply was helpful for you.
If you require any further assistance, please do not hesitate to ask.