expressappframework-115213-ui-construction-templates-in-winforms-how-to-access-the-bar-manager.md
WinForms applications use the Bar Manager to show an application’s menu when the ribbon interface is disabled (see IModelOptionsWin.FormStyle), and to display a nested Frame’s toolbar. This topic describes how to access the Bar Manager. Refer to the How to: Customize Action Controls topic to learn how to customize bar items.
Follow the steps below to access the BarManager object and customize its settings:
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Win.Controls;
using DevExpress.XtraBars;
// ...
public class BarManagerCustomizationWindowController : Controller {
protected override void OnActivated() {
base.OnActivated();
Frame.TemplateChanged += Frame_TemplateChanged;
}
private void Frame_TemplateChanged(object sender, EventArgs e) {
if (Frame.Template is IBarManagerHolder) {
BarManager manager = ((IBarManagerHolder)Frame.Template).BarManager;
manager.AllowCustomization = false;
}
}
protected override void OnDeactivated() {
Frame.TemplateChanged -= Frame_TemplateChanged;
base.OnDeactivated();
}
}
Run the application to ensure that bar customization is not allowed.