How to: Access the Navigation Dock Panel (in a WinForms Application)

This topic describes how to access and customize the Dock Panel used to display Navigation in WinForms applications.

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T275956.

The snippet below demonstrates these steps.

using System.Windows.Forms;
using DevExpress.ExpressApp;
// ...
public class HideNavigationPanelButtonsController : WindowController {
    public HideNavigationPanelButtonsController() {
        this.TargetWindowType = WindowType.Main;
    }
    protected override void OnActivated() {
        base.OnActivated();
        Frame.TemplateChanged += Frame_TemplateChanged;
    }
    private void Frame_TemplateChanged(object sender, EventArgs e) {
        Form form = (Form)Frame.Template;
        form.Load += Form_Load;
    }
    private void Form_Load(object sender, EventArgs e) {
        if(Frame.Template is DevExpress.ExpressApp.Win.Templates.INavigationPanelHolder) {
            DevExpress.XtraBars.Docking.DockPanel navigationPanel = 
                 ((DevExpress.ExpressApp.Win.Templates.INavigationPanelHolder)Frame.Template).DockPanelNavigation;
            navigationPanel.Options.ShowAutoHideButton = false;
            navigationPanel.Options.ShowCloseButton = false;
        }
    }
    protected override void OnDeactivated() {
        Frame.TemplateChanged -= Frame_TemplateChanged;
        base.OnDeactivated();
    }
}

In the code above, the BaseDockOptions.ShowAutoHideButton and BaseDockOptions.ShowCloseButton options are changed. You can use other properties of the DockPanelOptions as well.

Important

You can access the DockPanel object directly in the TemplateChanged event handler, but your settings will be overriden by XAF defaults in this instance. So, use the Form.Loadevent to override defaults.