I'm a XAML novice so I apologize if this seems like a a simple question. I have a problem similar to the one described here:
http://www.infragistics.com/community/forums/t/27446.aspx
The difference is that I am dealing with the ApplicationMenu and not a MenuTool. I have the same issue with the LargeImage that the OP had. I have attempted to adapt the code shown in that issue and have been able to show a static image in the correct way but clicking in that area of the menu does not fire the Command that I have bound to the ButtonTool that is displayed to the right of the image. Also, I'm unsure of how to make the image dynamic in the way that my ButtonTools are dynamic. How can I adapt the code show in the example I linked to a) show dynamic images based on a property of my ButtonViewModel and b) link the images to a Command also described in my ButtonViewModel.
Hello Drew,
Thank you for choosing Infragistics.
I have been looking into your issue and I would like to ask you if you would please send me a sample application where the issue is reproduced. Would you also please provide me with some additional information on the behavior you would like to achieve regarding the commands and the images you are using. Having this information would help me further investigate this matter for you.
Hello Tacho,
Thank you for your response. I have created a sample but am unable to upload the zip file. I am getting a 404 error when I push the Save button after browsing to my file. Please advise.
Thanks,
Drew
OK. It seems to work now. I've attached my solution in zip format. The behavior I'm seeing is similar to the post I originally linked to. Namely, the image I specified in the LargeImage attribute of the ButtonTool is showing up small the left of the text in the application menu while the area I expected the image to be is blank. I have used XAML adapted from that original issue and gotten a large image (not the one I want) to show up where I expected the image I specified to LargeImage to be. The behavior I'm looking for is to have the large image bound to the Icon property of my ButtonViewModel similar to how it is bound to the LargeImage attribute of the ButtonTool. In addition, I would like clicking the large image to execute the command that clicking the smaller image/text executes.
Thank you for the information you have provided.
I have been looking into the issue that you have described and I will need some more time to investigate it. I will follow up with my findings as soon as I am ready with my investigation.
Thank you for your patience and understanding.
Sincerely,
Tacho
Infragistics Inc.
www.infragistics.com
I have been looking further into your issue and I have modified the sample application you have provided and I have attached it for you to test it.
I have added an additional ToolMenuItem to the Application menu just for the example. In the ApplicationMenu's Resources of the MainWindowView I have added an EventSetter that handles the Loaded event of each ButtonTool in the ApplicationMenu's ToolMenuItems. In the event I have used the GetAncestorFromType and the GetDescendantFromName static methods of the Utilities class in order to eventually get the ContentPresenter instance that contains the clock image. Finally I have hooked for the PreviewMouseLeftButtonDown event of the ContentPresenter. In that event you should be able to handle your logic in regards to invoking certain commands or any other operation.
If you require any further assistance on this matter, please do not hesitate to ask.
https://filetransfer.infragistics.com/public.php?service=files&t=f6d16e4ad3fc1ad1f2fea267755903ed
Hi Tacho,
Sorry for the late reply, I was out yesterday. I haven't had a chance yet to fully digest what you've given me but I did notice that your response only addressed part of my concern. In addition to having the large image fire an event I need it to be the same icon that I have used for the LargeImage attribute of the ButtonTool (the refresh symbol). Ideally this would be done by binding to the Icon property of my ButtonViewModel class. Could you possibly look into this while I investigate whether I can implement your solution within the guidelines of my framework. Code-behind and MVVM in WPF are generally frowned upon.
Thanks, Drew
Thank you for your feedback.
I have been looking further into your issue and I have made new modifications to the sample application you have provided. In order to properly achieve the functionality you are looking for you should try to avoid putting a ButtonTool in the Header of the ToolMenuItem. The behavior that has been explained in the forum thread you have provided in your initial post applies to the ApplicationMenu, just as it does to the MenuTool since they share a common base and that logic/behavior is shared. Instead of trying to have an ItemTemplate that defines a ButtonTool – the ItemTemplate of a MenuItem is what goes into the ContentPresenter within its control template that displays the “Header” of the menu. You should be able to achieve the desired functionality by setting the necessary properties on the ToolMenuItem style you are using for the ItemContainerStyle and bind them to properties on your data item. I have bound those properties to your data item properties respectively. Another necessary change in order for this to work was to change the type of your “target” variable of your OnCommandMessageUpdated method from the ApplicationMenuCommandBehavior class to ToolMenuItem.
Another approach I can suggest to you is to bind the CommandParameter property directly to your data item. This way your ButtonViewModel would get passed as a parameter to your command when it is invoked. If you need to construct your CommandMessage and use it as the CommandParameter, then you could put a Converter on that binding that will create one from your ButtonViewModel. Consider the following snipper as an example:
You would then have to create the IValueConverter and reference it within your XAML.
Would you please take a look at the sample and if you have any further assistance on this matter, please do not hesitate to ask.
https://filetransfer.infragistics.com/public.php?service=files&t=a32476681e7864d557c197cd3a539c9a
Thanks for getting back to me. Unfortunately, there doesn't seem to be anything at the link you provided. Please advise.
-Drew