Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
960
Commands not launched by Contextmenu xammenuitems
posted

I have a XamDatatree in a UserControl and I've set a ContextMenu for some of the actions available on the main menu of the control inside the context menu.

The context menu is correctly shown but the click of the menu items does not execute the bound command.

The xammenuitems are all like the following

<ig:XamMenuItem  Command="lcmd:DataMaskCommands.NewNamesList">
	<ig:XamMenuItem.Header>
		<Label Content="{x:Static cr:NameListsEditorControlRx.mnuNewNamesList}"
		 HorizontalContentAlignment="Left" 
		 VerticalContentAlignment="Center"/>
		</ig:XamMenuItem.Header>
		<ig:XamMenuItem.Icon>
			<Image Source="/Myexe;Component/Images/btn_032_109.png" />
		</ig:XamMenuItem.Icon>
</ig:XamMenuItem>
The command binding is the following
<CommandBinding Command="{x:Static lcmd:DataMaskCommands.NewNamesList}" 
Executed="NewNamesList_Executed" CanExecute="NewNamesList_CanExecute" />

While this XamMenuItem works like a charm in the main menu of the window it does not execute the

command in the context menu. I suppose I've forgotten something fundamental in my code
but I don't know what it is, unfortunately, in the XamContextMenu samples, you use an Item clicked event handler
and there is no sample using the Command in a context menu.

if you have any clue

regards

Parents
  • 34810
    Offline posted

    Hello Sabrina,

    Thank you for your post.

    From the code that you have provided, I believe the reason your command on your XamContextMenu is not working is because you do not have the {x:Static ...} in front of it like in your CommandBinding. There also could be other things that I cannot see, such as the NewNamesList command not being instantiated in your DataMaskCommands class.

    I have attached a sample application to demonstrate a command working with the XamContextMenu on a XamDataTree in a user control. I encourage you to take a look at this sample and compare it to yours to see what may be wrong.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamContextMenuCommandingCase.zip
Reply Children