HypernovaDesktop Components · docs
Binarymission
WPF › Backstage Tab Control › BackstageTabControl

BackstageTabControl

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Controls.Office

A tab control laid out like the Office "File" backstage view: the tabs form a menu down the left, and the selected tab's page fills the space to its right, joined to the menu by an arrow-shaped highlight.

public class BackstageTabControl : TabControl

Inherits from / implements: TabControl

Remarks

Use it for full-window pages of settings, account details, document information, printing or export options – anywhere an application wants a backstage, or simply a settings window whose sections are listed on the left. It is a TabControl, so the tabs are ordinary TabItems: the HeaderedContentControl.Header is the menu entry and the ContentControl.Content is the page. Selection, keyboard navigation, binding through ItemsControl.ItemsSource and SelectionChanged all work as for any tab control.

The menu

The menu column is MenuItemWidth wide, painted with MenuBackgroundBrush, and each entry is MenuItemHeight tall, in MenuFontFamily at MenuFontSize. The pages start 15 logical pixels to the right of the menu. The menu is always on the left; TabControl.TabStripPlacement has no effect.

Selection and hover

The selected entry is drawn as a bar with a notch cut into its right-hand edge, pointing at the page – the shape is MenuItemSelectionPointerStemPathData – filled with MenuItemSelectedStateFillBrush, outlined with MenuItemSelectedStateBorderBrush and lettered in MenuItemSelectedForegroundBrush. It fades in over a third of a second. An entry under the pointer is highlighted with HoverTabItemBackgroundBrush and HoverTabItemBorderBrush.

Colours and skins

The default given on each brush is the one used when no Binarymission skin is in force: a light grey menu with black text and a green selection. With a skin (BinarySkinManager) the menu takes the skin's colours, and any brush you set on the control wins over both. The menu's colours do not follow the Windows theme, so if you change MenuBackgroundBrush, change MenuItemForegroundBrush with it.

Examples

A document backstage with an Office-blue selection.

<Window x:Class="Editor.BackstageWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:office="clr-namespace:Binarymission.WPF.Controls.Office;assembly=Binarymission.WPF.Controls.BackstageTabControl"
        Title="File" Width="900" Height="560">

    <office:BackstageTabControl MenuItemWidth="190" MenuItemHeight="40" MenuFontSize="14"
                                MenuItemSelectedStateFillBrush="#2B579A"
                                MenuItemSelectedStateBorderBrush="#1E3F70"
                                HoverTabItemBackgroundBrush="#DCE6F4"
                                HoverTabItemBorderBrush="Transparent">
        <TabItem Header="Info">
            <StackPanel Margin="0,16">
                <TextBlock FontSize="24" Text="Quarterly report.docx" />
                <TextBlock Margin="0,8" Text="Last modified 14:32 by A. Patel" />
            </StackPanel>
        </TabItem>
        <TabItem Header="Recent">
            <ListBox ItemsSource="{Binding RecentDocuments}" />
        </TabItem>
        <TabItem Header="Print">
            <TextBlock Margin="0,16" Text="Printer and page settings go here." />
        </TabItem>
        <TabItem Header="Share">
            <TextBlock Margin="0,16" Text="Send as an attachment, or share a link." />
        </TabItem>
        <TabItem Header="Options" />
    </office:BackstageTabControl>
</Window>

The same control filled from code.

using System.Windows.Controls;
using System.Windows.Media;
using Binarymission.WPF.Controls.Office;

BackstageTabControl backstage = new BackstageTabControl
{
    MenuItemWidth = 190,
    MenuItemSelectedStateFillBrush = new SolidColorBrush(Color.FromRgb(0x2B, 0x57, 0x9A))
};
backstage.Items.Add(new TabItem { Header = "Info", Content = new TextBlock { Text = "Quarterly report.docx" } });
backstage.Items.Add(new TabItem { Header = "Print", Content = new TextBlock { Text = "Printer settings" } });
backstage.SelectedIndex = 0;

See also

Members at a glance

Properties
HoverTabItemBackgroundBrushGets or sets the fill of a menu entry while the pointer is over it.
HoverTabItemBorderBrushGets or sets the colour of the lines drawn above, below and to the right of a menu entry while the pointer is over it.
MenuBackgroundBrushGets or sets the background of the menu column down the left of the control.
MenuBorderBrushGets or sets the colour of the edge round the menu column.
MenuBorderThicknessGets or sets the width of the edge drawn round the menu column on each side.
MenuFontFamilyGets or sets the typeface of the text in the menu.
MenuFontSizeGets or sets the size of the text in the menu.
MenuItemForegroundBrushGets or sets the colour of the menu entries' text, other than the selected one.
MenuItemHeightGets or sets the height of each menu entry.
MenuItemSelectedForegroundBrushGets or sets the colour of the selected menu entry's text.
MenuItemSelectedStateBorderBrushGets or sets the colour of the outline drawn round the selected menu entry.
MenuItemSelectedStateBorderThicknessGets or sets the width of the outline round the selected menu entry on each side.
MenuItemSelectedStateFillBrushGets or sets the fill of the selected menu entry – the arrow-shaped bar that points at the page.
MenuItemSelectionPointerStemPathDataGets or sets the shape of the highlight drawn behind the selected menu entry.
MenuItemWidthGets or sets the width of the menu column, and so of every menu entry.
Fields
HoverTabItemBackgroundBrushPropertyIdentifies the HoverTabItemBackgroundBrush dependency property.
HoverTabItemBorderBrushPropertyIdentifies the HoverTabItemBorderBrush dependency property.
MenuBackgroundBrushPropertyIdentifies the MenuBackgroundBrush dependency property.
MenuBorderBrushPropertyIdentifies the MenuBorderBrush dependency property.
MenuBorderThicknessPropertyIdentifies the MenuBorderThickness dependency property.
MenuFontFamilyPropertyIdentifies the MenuFontFamily dependency property.
MenuFontSizePropertyIdentifies the MenuFontSize dependency property.
MenuItemForegroundBrushPropertyIdentifies the MenuItemForegroundBrush dependency property.
MenuItemHeightPropertyIdentifies the MenuItemHeight dependency property.
MenuItemSelectedForegroundBrushPropertyIdentifies the MenuItemSelectedForegroundBrush dependency property.
MenuItemSelectedStateBorderBrushPropertyIdentifies the MenuItemSelectedStateBorderBrush dependency property.
MenuItemSelectedStateBorderThicknessPropertyIdentifies the MenuItemSelectedStateBorderThickness dependency property.
MenuItemSelectedStateFillBrushPropertyIdentifies the MenuItemSelectedStateFillBrush dependency property.
MenuItemSelectionPointerStemPathDataPropertyIdentifies the MenuItemSelectionPointerStemPathData dependency property.
MenuItemWidthPropertyIdentifies the MenuItemWidth dependency property.

Properties

HoverTabItemBackgroundBrush

public Brush HoverTabItemBackgroundBrush

Gets or sets the fill of a menu entry while the pointer is over it.

Value
The default is a pale blue (#E5EFFA).
Remarks

The highlight fades in over about an eighth of a second, and is not shown on the selected entry.

See also

HoverTabItemBorderBrush

public Brush HoverTabItemBorderBrush

Gets or sets the colour of the lines drawn above, below and to the right of a menu entry while the pointer is over it.

Value
The default is a strong blue (#1F68CC).
Remarks

Set Brushes.Transparent for a hover highlight with no lines, as in recent versions of Office. The selected entry shows no hover highlight.

See also

MenuBackgroundBrush

public Brush MenuBackgroundBrush

Gets or sets the background of the menu column down the left of the control.

Value
The default is a light blue-grey (#E8ECF0).
Remarks

The column fills the full height of the control, below the last entry as well. If you make it dark, set MenuItemForegroundBrush to a light colour at the same time.

See also

MenuBorderBrush

public Brush MenuBorderBrush

Gets or sets the colour of the edge round the menu column.

Value
The default is Colors.LightGray.
Remarks

Nothing is drawn until MenuBorderThickness is set, which is 0 by default.

See also

MenuBorderThickness

public Thickness MenuBorderThickness

Gets or sets the width of the edge drawn round the menu column on each side.

Value
A thickness in logical pixels (1/96 inch). The default is 0: no edge.
Remarks

A single pixel on the right only (0,0,1,0) separates the menu from the pages. The edge is drawn with MenuBorderBrush.

See also

MenuFontFamily

public FontFamily MenuFontFamily

Gets or sets the typeface of the text in the menu.

Value
The default is MenuFontFamily, the typeface of Windows menus on the machine.
See also

MenuFontSize

public double MenuFontSize

Gets or sets the size of the text in the menu.

Value
A size in logical pixels (1/96 inch). The default is MenuFontSize, the size of the text in Windows menus on the machine.
Remarks

Office's own backstage uses a larger size than its menus; 14 to 16 is typical. Raise MenuItemHeight with it if the text no longer fits.

See also

MenuItemForegroundBrush

public Brush MenuItemForegroundBrush

Gets or sets the colour of the menu entries' text, other than the selected one.

Value
The default is black.
Remarks

Set it whenever MenuBackgroundBrush is set: the two defaults are a matched pair – dark text on a light grey column – and neither follows the Windows theme, so a dark menu background with the default text cannot be read. It colours text headers, and any header content that inherits Foreground.

See also

MenuItemHeight

public double MenuItemHeight

Gets or sets the height of each menu entry.

Value
A height in logical pixels (1/96 inch). The default is 42.
Remarks

The selection and hover highlights are drawn at this height, and the header is centred in it. Entries are stacked from the top of the menu with no gap between them.

See also

MenuItemSelectedForegroundBrush

public Brush MenuItemSelectedForegroundBrush

Gets or sets the colour of the selected menu entry's text.

Value
The default is white, to read against the green selection.
Remarks

The text switches to this colour as soon as the entry is selected, and back to MenuItemForegroundBrush when another entry is chosen.

See also

MenuItemSelectedStateBorderBrush

public Brush MenuItemSelectedStateBorderBrush

Gets or sets the colour of the outline drawn round the selected menu entry.

Value
The default is the same green radial gradient as MenuItemSelectedStateFillBrush, so the outline merges into the fill.
Remarks

The outline's width on each side is MenuItemSelectedStateBorderThickness; by default it is open on the right, where the entry meets the page. Set a darker shade of the fill colour for a crisp edge.

See also

MenuItemSelectedStateBorderThickness

public Thickness MenuItemSelectedStateBorderThickness

Gets or sets the width of the outline round the selected menu entry on each side.

Value
A thickness in logical pixels (1/96 inch). The default is 2,2,0,2: two pixels on the left, top and bottom, and none on the right, where the entry meets the page.
See also

MenuItemSelectedStateFillBrush

public Brush MenuItemSelectedStateFillBrush

Gets or sets the fill of the selected menu entry – the arrow-shaped bar that points at the page.

Value
The default is a radial gradient from green, towards the left of the entry, to light green.
Remarks

Choose a colour that MenuItemSelectedForegroundBrush reads well against; the default white text suits any strong, dark colour. The shape it fills is MenuItemSelectionPointerStemPathData.

Example
<office:BackstageTabControl MenuItemSelectedStateFillBrush="#2B579A"
                            MenuItemSelectedStateBorderBrush="#1E3F70" />
See also

MenuItemSelectionPointerStemPathData

public Geometry MenuItemSelectionPointerStemPathData

Gets or sets the shape of the highlight drawn behind the selected menu entry.

Value
A geometry that is stretched to fill the entry. The default is a bar with a small arrow-shaped notch cut into the middle of its right-hand edge, pointing at the page.
Remarks

Only the outline's proportions matter: the shape is stretched to the entry's width and MenuItemHeight, whatever its own coordinates. It is filled with MenuItemSelectedStateFillBrush.

In XAML it can be given in path markup.

Example
<!-- A plain bar ending in a point on the right, in place of the notch. -->
<office:BackstageTabControl MenuItemSelectionPointerStemPathData="M0,0 L90,0 100,10 90,20 0,20 Z" />

MenuItemWidth

public double MenuItemWidth

Gets or sets the width of the menu column, and so of every menu entry.

Value
A width in logical pixels (1/96 inch). The default is 175.
Remarks

Entries are not wrapped or trimmed: make the column wide enough for the longest header at MenuFontSize. The pages take the rest of the control's width.

See also

Fields

HoverTabItemBackgroundBrushProperty static

public static readonly DependencyProperty HoverTabItemBackgroundBrushProperty

Identifies the HoverTabItemBackgroundBrush dependency property.

HoverTabItemBorderBrushProperty static

public static readonly DependencyProperty HoverTabItemBorderBrushProperty

Identifies the HoverTabItemBorderBrush dependency property.

MenuBackgroundBrushProperty static

public static readonly DependencyProperty MenuBackgroundBrushProperty

Identifies the MenuBackgroundBrush dependency property.

MenuBorderBrushProperty static

public static readonly DependencyProperty MenuBorderBrushProperty

Identifies the MenuBorderBrush dependency property.

MenuBorderThicknessProperty static

public static readonly DependencyProperty MenuBorderThicknessProperty

Identifies the MenuBorderThickness dependency property.

MenuFontFamilyProperty static

public static readonly DependencyProperty MenuFontFamilyProperty

Identifies the MenuFontFamily dependency property.

MenuFontSizeProperty static

public static readonly DependencyProperty MenuFontSizeProperty

Identifies the MenuFontSize dependency property.

MenuItemForegroundBrushProperty static

public static readonly DependencyProperty MenuItemForegroundBrushProperty

Identifies the MenuItemForegroundBrush dependency property.

MenuItemHeightProperty static

public static readonly DependencyProperty MenuItemHeightProperty

Identifies the MenuItemHeight dependency property.

MenuItemSelectedForegroundBrushProperty static

public static readonly DependencyProperty MenuItemSelectedForegroundBrushProperty

Identifies the MenuItemSelectedForegroundBrush dependency property.

MenuItemSelectedStateBorderBrushProperty static

public static readonly DependencyProperty MenuItemSelectedStateBorderBrushProperty

Identifies the MenuItemSelectedStateBorderBrush dependency property.

MenuItemSelectedStateBorderThicknessProperty static

public static readonly DependencyProperty MenuItemSelectedStateBorderThicknessProperty

Identifies the MenuItemSelectedStateBorderThickness dependency property.

MenuItemSelectedStateFillBrushProperty static

public static readonly DependencyProperty MenuItemSelectedStateFillBrushProperty

Identifies the MenuItemSelectedStateFillBrush dependency property.

MenuItemSelectionPointerStemPathDataProperty static

public static readonly DependencyProperty MenuItemSelectionPointerStemPathDataProperty

Identifies the MenuItemSelectionPointerStemPathData dependency property.

MenuItemWidthProperty static

public static readonly DependencyProperty MenuItemWidthProperty

Identifies the MenuItemWidth dependency property.