Opening a RadContextMenu from Codebehind with using UIElement for Prism Command binding

0 Answers 58 Views
Top achievements
Rank 1
Peter asked on 16 Mar 2023, 02:48 PM


We have switched over from using WPF's built in ContextMenu's to RadContextMenus and we are using Prism Delegated commands.

We have set the "tag" property of the UI element (that has the RadContextMenu attached to it) to an ElementReference to the containing window so that we can then use UIElement.Tag to get back to the Window to then bind to it's PrintCommand.

This all works well, however if we open the ContextMenu from code behind using contMenu.IsOpen = True then the UIElement property is not being set to anything so the command cannot be found.

Is there a different way we should be bindiing the RadContextMenu items to the view commands?



<telerik:RadContextMenu  DataContext="{Binding Path=UIElement.Tag, RelativeSource={RelativeSource Self}}" InheritDataContext="False">
   <telerik:RadMenuItem Header="Print" InputGestureText="Ctrl+P"
                                       Command="{Binding PrintCommand}" />

Telerik team
commented on 21 Mar 2023, 11:05 AM

Although I understand the general scenario, would it be possible to provide a bit more code, so that I could try to include it in a sample project and investigate this behavior?

No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question