expressappframework-116417-app-shell-and-base-infrastructure-navigation-access-the-office-navigation-bar.md
This topic demonstrates how to access the Office Navigation Bar used to show the navigation root groups when the OutlookStyleMainRibbonForm Template is used in a WinForms application.
Perform the following steps to access the OfficeNavigationBar object and customize its settings.
using DevExpress.ExpressApp.Win.Templates;
using DevExpress.XtraBars.Ribbon;
//...
public class OfficeNavigationBarCustomizationController : WindowController {
private void Frame_TemplateChanged(object sender, EventArgs e) {
Form form = Frame.Template as Form;
if(form != null) {
form.Load += Form_Load;
}
}
private void Form_Load(object sender, EventArgs e) {
IOfficeNavigationBarHolder officeNavigationBarHolder = sender as IOfficeNavigationBarHolder;
if(officeNavigationBarHolder != null) {
officeNavigationBarHolder.OfficeNavigationBar.MaxItemCount = 4;
}
}
protected override void OnActivated() {
base.OnActivated();
Frame.TemplateChanged += Frame_TemplateChanged;
}
protected override void OnDeactivated() {
Frame.TemplateChanged -= Frame_TemplateChanged;
base.OnDeactivated();
}
public OfficeNavigationBarCustomizationController() {
TargetWindowType = WindowType.Main;
}
}
Run the application to ensure that the maximum number of visible OfficeNavigationBar items is 4.