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

Assigning RadContextMenu to Custom Templated Control

1 Answer 114 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Gregory
Top achievements
Rank 1
Gregory asked on 25 Oct 2010, 06:45 PM
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?

Thanks,

Greg

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 26 Oct 2010, 07:34 AM
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,
Hristo
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
ContextMenu
Asked by
Gregory
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or