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:
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
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