devexpressribbonxaf

XAF: How to minimize ribbon from code in XAF Windows App


I want to minimize the ribbon when user click on particular navigation Item. For example - when User clicks on Dashboard nav item, I want the ribbon minimized, and automatically "maximized" on others.

How can I do that ?


Solution

  • I've found that I can simple access the ribbon in the ViewController. So like usual in XAF, override "OnActivated" and do the magic there

        protected override void OnActivated()
        {
            if (Frame.Template != null)
            {
                ((XtraFormTemplateBase)Frame.Template)).RibbonTransformer.Ribbon
                                               .Minimized = View.Id == "TestView;
            }
            base.OnActivated();
        }
    

    I got a couple of errors while accessing Frame.Template being NULL when I'd hit a dashboardview, with many nested ListView in it. Make sure You don't forget to check it :)