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 codebut I don't know what it is, unfortunately, in the XamContextMenu samples, you use an Item clicked event handlerand there is no sample using the Command in a context menu.
if you have any clue
regards
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,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hi Andrew thank you for the sample, Unfortunately even doing whar you propose it does not work and I've been able to reproduce the problem on your sample project,is there a way for me to send you the project so you can take a look and see what's wrong?
Thank you in advance
Here is the zip file with the modified sample sorry I've found only now how to send an attachment to the messages...
regards sabrina
I have not been able to reproduce this behavior that you are referring to. I see that you have the specific version of the assemblies in your project set to "false." I am using version 14.2.20142.2081. The steps that I have taken to try to reproduce this is to click a XamDataTree node, since you have e.CanExecute = myTree.ActiveDataItem != null. Then, after bringing up the context menu, I click the menu item, and the message box shows.
Do the specific versions of the assemblies we are using match? If they do, are there any environmental specifications to your machine such as culture or otherwise that you can provide so that I can try to reproduce this behavior you are seeing?
My version of the assemblies is 1000 so I think the 14.2 without service releases
if it can be a service release issue please let me know and I'll upgrade.
on my machine in the project I sent to you when I click the context menu the message box does not appear.
I have been looking through our development issue tracking system, and I haven't seen anything regarding a fix related to the XamContextMenu working with commands that has been recent. Nevertheless, I would still recommend upgrading to the most recent version of 14.2 and trying your project again in case I may have missed something. You can download the most recent service release by accessing your account at https://ko.infragistics.com/my-account/keys-and-downloads.
Ok Andrew, I've updated to the latest service release, 14.2.20142.2081 and after the update the context menu calls the commands correctly.
so maybe it was a problem solved by the solution to something else :)
thank you for the support and patience
I am glad that the upgrade to the most recent service release solved this issue you were having.