expressappframework-115214-ui-construction-templates-in-winforms-how-to-access-the-ribbon-control.md
This topic demonstrates how to access the Ribbon control used to show the WinForms application menu when the IModelOptionsWin.FormStyle property is set to Ribbon (when the ribbon interface is enabled). Refer to the How to: Customize Action Controls topic to learn how to customize bar items.
Follow the steps below to access the RibbonControl object and customize its settings:
using System;
using DevExpress.ExpressApp;
using DevExpress.XtraBars.Ribbon;
using DevExpress.Utils;
// ...
public class RibbonCustomizationWindowController : WindowController {
protected override void OnActivated() {
base.OnActivated();
Window.TemplateChanged += Window_TemplateChanged;
}
private void Window_TemplateChanged(object sender, EventArgs e) {
RibbonForm ribbonForm = Frame.Template as RibbonForm;
if (ribbonForm != null && ribbonForm.Ribbon != null) {
RibbonControl ribbon = ribbonForm.Ribbon;
ribbon.PageHeaderMinWidth = 100;
ribbon.ShowExpandCollapseButton = DefaultBoolean.False;
}
}
protected override void OnDeactivated() {
Window.TemplateChanged -= Window_TemplateChanged;
base.OnDeactivated();
}
}
Run the application to ensure that Ribbon control customizations are applied.