I want to have a custom contextmenu per cell, I implemented this succesfully with the example given in this thread.
Now I want to add the functionality that the contextmenu will be displayed based on the row where the cursor is and the contextmenu is called, in another thread they point me to the RadContextMenu example of the Telerik Demos.
So I created a custom class which inherits from the RadContextMenu and attach an implementation for the open event:
sender, RoutedEventArgs e)
RadContextMenu menu = (RadContextMenu)sender;
GridViewRow row = menu.GetClickedElement<GridViewRow>();
row.IsSelected = row.IsCurrent =
GridViewCell cell = menu.GetClickedElement<GridViewCell>();
I created 4 different contextmenus, 1 default and 3 other that depend on the cell where the user calls the contextmenu.
When I try setting this custom contextmenu in XAML as default for my GridView and as contextmenu for some cells using styles. I receive an InvalidOperationException stating that the given contextmenu is not a valid value for the ContextMenu property?
It worked with the regular ContextMenu, but when I change my custom ContextMenu to inherit from this class I cant call the function GetClickedElement<GridViewCell>()?
How can I solve this, I dont exactly understand why I get this exception with RadContextMenu and not with a regular ContextMenu.
Any help would be appreciated.