Panel Bar
An Outlook-style navigation pane: a stack of large section buttons – Mail, Calendar, Contacts – each showing its own page of controls above them, with overflow icons, a chevron menu and an optional collapse to a narrow rail.
Assembly
| Assembly | Binarymission.WinForms.Controls.PanelBar.dll |
| Root namespace | Binarymission.WinForms.Controls.NavigationControls |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
| Depends on | BinaryMenu |
Overview
What it is for
Use the bar down the side of a main window to switch between the sections of an application.
Each section is a BinaryPanelBarButton; clicking it fills the area above the buttons
with the section's BinaryPanelBarContainedPanel and puts its text in the header.
Key concepts
- Buttons and pages. Give each button a
BinaryPanelBarButton.ButtonText, an image and aBinaryPanelBarButton.ContainedPanelholding the section's controls, and add it withAddBinaryPanelBarButton. One button is selected at a time. - Shown and hidden buttons.
HowManyPanelButtonsToShowlarge buttons are stacked at the bottom; the rest appear as small icons in the strip under them. The user moves buttons between the two by dragging the gripper above the stack or with the chevron menu's "Show More Buttons" and "Show Fewer Buttons". - Available buttons. A button whose
BinaryPanelBarButton.NotAvailableForUseis set is hidden altogether. The user chooses which are available from the chevron menu's "Add or Remove Buttons", or the "Navigation Pane Options" dialog (AddShowNavigationOptionsMenuItem). - Collapsing. With
RenderInOutlookStyleExpandCollapseModeon, an arrow in the header collapses the bar to a narrow rail; clicking the rail opens the selected page in a flyout beside it.
Appearance
XPThemeToEmulate picks a Windows XP palette (olive by default), or
XPTheme.None for StartColor and EndColor.
ItemColorRenderingStyle chooses a plain gradient, an Office-style finish or the system
colours, and the Button...Color properties colour the hovered and selected buttons. Metrics
are in logical pixels (1/96 inch) and are scaled with the display.
Getting started
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.NavigationControls;
public class MailForm : Form
{
private readonly BinaryPanelBar navigation = new BinaryPanelBar();
private readonly StatusStrip status = new StatusStrip();
public MailForm()
{
Text = "Mail";
Size = new Size(960, 640);
status.Items.Add("Mail");
navigation.Dock = DockStyle.Left;
navigation.Width = 240;
navigation.XPThemeToEmulate = XPTheme.Blue;
navigation.ItemColorRenderingStyle = PanelBarItemColorRenderingStyle.OfficeStyleRenderer;
navigation.RenderInOutlookStyleExpandCollapseMode = true; // collapse arrow in the header
navigation.AddShowNavigationOptionsMenuItem = true;
var folders = new TreeView();
folders.Nodes.Add("Inbox");
folders.Nodes.Add("Sent Items");
AddSection("Mail", "Images\\mail", folders);
AddSection("Calendar", "Images\\calendar", new MonthCalendar());
AddSection("Contacts", "Images\\contacts", new ListBox { Items = { "Accounts team", "Suppliers" } });
navigation.HowManyPanelButtonsToShow = 2; // the third shows as a small icon
navigation.BinaryPanelBarButtonClicked += (sender, e) =>
status.Items[0].Text = ((BinaryPanelBarButton)sender).ButtonText;
Controls.Add(navigation);
Controls.Add(status);
}
private void AddSection(string title, string imagePath, Control content)
{
var page = new BinaryPanelBarContainedPanel();
content.Dock = DockStyle.Fill;
page.Controls.Add(content);
var button = new BinaryPanelBarButton(navigation) // the bar, for drawing on the collapsed rail
{
ButtonText = title,
ButtonImage = new Bitmap(imagePath + "-24.png"),
ButtonSmallImage = new Bitmap(imagePath + "-16.png"),
ContainedPanel = page, // set before the button is added
};
navigation.AddBinaryPanelBarButton(button);
}
}API reference
Binarymission.WinForms.Controls.NavigationControls
class BinaryPanelBar | An Outlook-style navigation pane: a stack of large section buttons - Mail, Calendar, Contacts - each showing its own page of controls above them, with overflow icons, a chevron menu and an optional collapse to a narrow rail. |
class BinaryPanelBarButton | One section of a BinaryPanelBar: a large button with an image and a title which, when clicked, shows its page of controls - its ContainedPanel - in the bar. |
delegate BinaryPanelBarButtonNotAvailableForUseChangingHandler | Represents the method that handles BinaryPanelBarButtonNotAvailableForUseChanging. |
class BinaryPanelBarContainedPanel | The page of a BinaryPanelBarButton: a scrolling panel holding a section's controls, which the BinaryPanelBar shows while that button is selected. |
class PanelBarAboutToCollapseOrExpandEventArgs | Provides data for AboutToCollapseOrExpand, and lets the handler stop the bar collapsing or expanding. |
class PanelBarAddShowNavigationOptionsMenuResourceProvider | The texts of a BinaryPanelBar's chevron menu, settable so that an application can translate the menu. |
enum PanelBarBorderStyle | Specifies the border drawn round a BinaryPanelBar or one of its buttons. |
class PanelBarCollapseExpandEventArgs | Provides data for CollapseExpandButtonClicked. |
delegate PanelBarContextMenuShowNavigationPaneOptionsHandler | Represents the method that handles ContextMenuShowNavigationPaneOptionsClicked. |
delegate PanelBarGripperHandleMovedHandler | Represents the method that handles GripperHandleMoved. |
enum PanelBarItemColorRenderingStyle | Specifies how a BinaryPanelBar fills its buttons and header strip. |
class PanelBarNavigationOptions | Carries the data of ContextMenuShowNavigationPaneOptionsClicked: the bar's buttons, and whether to keep the built-in options dialog closed. |
delegate PanelBarXPThemeChangedHandler | Represents the method that handles XpThemeChanged. |
delegate PanelBarXPThemeChangingHandler | Represents the method that handles XpThemeChanging. |
delegate ShowMoreOrFewerPanelBarButtonsMenuItemClickedHandler | Represents the method that handles ShowMoreButtonsMenuItemClicked and ShowFewerButtonsMenuItemClicked. |
enum XPTheme | Specifies the Windows XP palette a BinaryPanelBar is drawn in, or none. |
Binarymission.WinForms.Controls.NavigationControls.Designers
class BinaryPanelBarControlActionList | Supplies the smart tag panel shown for a BinaryPanelBar on the Windows Forms designer surface: the theme, rendering style, borders, collapsing, gripper and header settings. |