Using this example as a base, I created a custom class to add a special right click menu onto any RadGridView item:
Example: https://github.com/telerik/xaml-sdk/blob/master/GridView/CopyPasteFunctionality/GridViewClipboardContextMenu.cs
Code:
public GridViewCopyContextMenu(RadGridView grid){ this.gridView = grid; Image iconCopy = new Image() { Stretch = Stretch.None, Source = new BitmapImage(new Uri("/Images/copyIcon.png", UriKind.RelativeOrAbsolute)) }; this.contextMenu = new RadContextMenu(); this.contextMenu.Items.Add(new RadMenuItem() { Header = GridViewCopyContextMenu.COPY_SELECTED_CELL_WITHOUT_HEADER_HEADER }); this.contextMenu.Items.Add(new RadMenuItem() { Header = GridViewCopyContextMenu.COPY_SELECTED_CELL_WITH_HEADER_HEADER }); this.contextMenu.Items.Add(new RadMenuItem() { Header = GridViewCopyContextMenu.COPY_SELECTED_ROW_WITHOUT_HEADER_HEADER }); this.contextMenu.Items.Add(new RadMenuItem() { Header = GridViewCopyContextMenu.COPY_SELECTED_ROW_WITH_HEADER_HEADER }); this.contextMenu.Items.Add(new RadMenuItem() { Header = GridViewCopyContextMenu.COPY_ALL_ROW_WITHOUT_HEADER_HEADER }); this.contextMenu.Items.Add(new RadMenuItem() { Header = GridViewCopyContextMenu.COPY_ALL_ROW_WITH_HEADER_HEADER }); this.contextMenu.Opened += RadContextMenu_Opened; this.contextMenu.ItemClick += RadContextMenu_ItemClick; RadContextMenu.SetContextMenu(this.gridView, this.contextMenu);}If I modify any single item to add "Icon = iconCopy, " into the properties, I get the following runtime error:
Category: ParserError
Message: Failed to assign to property 'System.Windows.Controls.ContentPresenter.Content'.
I've tried using "/Images/copyIcon.png" and "MyProject;component/Images/copyIcon.png"; the end result is the same. If I put the source with the either format in xaml on a RadContextMenu, I can see the actual intended image during design time, but I get the same runtime error during runtime.
What can I do to fix this so my icon will show? I am using Silverlight 5, on Runtime Version v4.0.30319, with Telerik Version 2014.1.224.1050.
Thanks