Assigning RadContextMenu to Custom Templated Control

2 posts, 0 answers
  1. Gregory
    Gregory avatar
    10 posts
    Member since:
    Aug 2010

    Posted 25 Oct 2010 Link to this post

    I have several custom WPF controls whose visual representations are defined by a XAML template. My goal is to define a RadContextMenu in a ResourceDictionary and then, in code, assign it to be the context menu for my custom controls, similary to the following:

    ResourceDictionary resourceDictionary = new ResourceDictionary();
                resourceDictionary.Source = new Uri(
                    "MyLibrary;component/Resources/Resources.xaml", UriKind.Relative);
                Grid mainGrid = Template.FindName("mainGrid", this) as Grid;
                if(mainGrid != null)
                    RadContextMenu.SetContextMenu(this, (RadContextMenu)resourceDictionary["DefaultControlContextMenu"]);

    At runtime, the RadContextMenu gets assigned correctly, but whenever I right-click on my custom control the following exception is thrown:

    System.InvalidOperationException: Cannot perform action because the specified Storyboard was not applied to this object for interactive control.

    I've noticed that others have gotten a similar exception with the RadTreeView and RadTransitionControl, and I need to know what to do for a workaround on this. Is the problem related to the fact that I am using a control template?


  2. Hristo
    Hristo avatar
    832 posts

    Posted 26 Oct 2010 Link to this post

    Hello Gregory,

    Attaching one instance of RadContextMenu to multiple controls is not supported scenario. 
    Could you send us example so that we can investigate it?

    Sincerely yours,
    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
Back to Top