Build a menu using the WPF Ribbon. My application is in the MVVM pattern. To connect the RibbonButton the ViewModel, use the form:
Command="{Binding Logoff}"
It works correctly.
Now, using the same command on RibbonApplicationMenuItem:
Command="{Binding Logoff}"
does not raise any calls or event. What do I need for the RibbonApplicationMenuItem call a method that is in the ViewModel? When I create methods in the codebehind, it works. But this goes against what I’m developing MVVM architecture.
Would have any suggestions to make the RibbonApplicationMenuItem be connected via binding to ViewModel?
After several searches, I found the solution to the problem. Ribbon in the package has the file MicrosoftRibbonForWPFSourceAndSamples, which has a great example of how to work with RibbonApplicationMenuItem. I used the method DelegateCommand, which comes as an example in this package.
I used the following syntax in the constructor of View:
I hope it’s useful for someone else.
Best Regards