This is a migrated thread and some comments may be shown as answers.

ContextMenu row commands

1 Answer 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tyree
Top achievements
Rank 2
Tyree asked on 09 Aug 2010, 04:50 PM
We have backed the grid with a collection of RowViewModels. So each row has its own Commands - like Save, Delete, etc. I was hoping you could add a context menu to the GridView and that its "Command" attribute would have each row as its context but alas it does not. So, is there any way to make the context menu have context of the row so the Command just works, or do I have to wire the Command each time it opens?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 10 Aug 2010, 11:02 AM
Hi Tyree,

You can get the clicked row and use it as a DataContext during the ItemClick event of the ContextMenu. For example:

private void GridContextMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    RadContextMenu menu = (RadContextMenu)sender;
    RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
    GridViewRow row = menu.GetClickedElement<GridViewRow>();           
    this.clubsGrid.Items.Remove(row.DataContext);                              
}


 

Best wishes,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Tyree
Top achievements
Rank 2
Answers by
Maya
Telerik team
Share this question
or