Search This Blog

Thursday, October 13, 2016

How to map Actions to a certain RibbonPage and RibbonGroup via the Application Model

This is my second post about advanced ribbon menu customizations in XAF WinForms apps. This time I want to repost two possible solutions for the aforementioned task after reviewing and updating the code of one good (and never old - Hi, Noxe!:-)) customer recently. This work was done after an interview about my Simplifying customization of Action controls - YOUR FEEDBACK IS NEEDED! post. Take a look at it if you haven't yet. 


Long story short, refer to the https://www.devexpress.com/kb=S134617 ticket and find two possible Controller implementations. Even though the first one (RibbonFromModelWithEventController.cs) requires more code to implement, I like it more, because it does not require you to create an Action Container node manually in the Model Editor. With the first one, you just specify the TargetRibbonPage and TargetRibbonGroup properties for a required Action under the ActionDesign node and you are done:


In any case, I suggest you play with both implementations and watch the attached video to determine what is more suitable for you. I look forward to hearing from you in the comments section or in the Support Center, as always.


I do not want to focus much on the Controller code itself, just want to note that there we extended the standard IModelAction interface corresponding to the ActionDesign | Action node and then handled these new options in our code. This is one of my favorite Application Model features, which is also truly loved by our customers. In fact, everything you see in our framework is built using the same simple principle: you have certain UI metadata or settings store and have some Controllers in modules that create/customize visual controls accordingly. To learn more about this, refer to the Concepts > Application Model > Extend and Customize the Application Model in Code article in our online documentation. This is a really cool feature and it can help you create a more reusable code.

4 comments:

  1. I attempted to try it but the typeof e.Template is never RibbonForm in Application_CustomizeTemplate, however I'm using ribbon UI.

    ReplyDelete
    Replies
    1. Are you probably using the old WinForms templates (UseOldTemplates=true)? This code is designed for the New templates only (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112618). If this does not help, please contact us via the Support Center and attach your project for further research.

      Delete