HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonTabItem

BinaryRibbonTabItem

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

One tab of a BinaryRibbonBarPanel: a heading in the tab row, and the BinaryRibbonGroups of commands shown beneath it while it is selected.

public class BinaryRibbonTabItem : Control, IBinaryRibbonKeyTipControl

Inherits from / implements: Control, IBinaryRibbonKeyTipControl

Remarks

Gather the commands for one activity on a tab – Home, Insert, Review – and give the tab a short HeaderText. Its content is AvailableRibbonGroups, laid out from left to right; when the window is too narrow, the last group gives way first.

Selecting

A click selects the tab, and a double-click switches the ribbon between showing its commands and showing only its tabs. From code, set BinaryRibbonBarPanel.SelectedTabItem or BinaryRibbonBarPanel.SelectedTabIndex; IsCurrentlySelected says which tab is selected.

Keyboard and contextual tabs

A key tip set with BinaryKeyTip.SetAccessKey selects the tab and then shows the key tips of its commands. A tab added to a BinaryRibbonControlContextualTabSet rather than to BinaryRibbonBarPanel.Tabs appears only while that set is on show. Collapse a tab (UIElement.Visibility) to take it off the tab row.

Examples

<bm:BinaryRibbonTabItem HeaderText="Review" SmallImage="Images/Review16.png" bm:BinaryKeyTip.AccessKey="R">
    <bm:BinaryRibbonGroup TitleText="Proofing">
        <bm:BinaryRibbonButton Content="Spelling" LargeImage="Images/Spelling32.png" Click="OnSpelling" />
    </bm:BinaryRibbonGroup>
    <bm:BinaryRibbonGroup TitleText="Approval">
        <bm:BinaryRibbonButton Content="Approve" LargeImage="Images/Approve32.png" Click="OnApprove" />
        <bm:BinaryRibbonButton Content="Reject" LargeImage="Images/Reject32.png" Click="OnReject" />
    </bm:BinaryRibbonGroup>
</bm:BinaryRibbonTabItem>

See also

Members at a glance

Constructors
BinaryRibbonTabItemCreates an empty tab; give it a HeaderText and add groups to AvailableRibbonGroups.
Properties
AvailableRibbonGroupsGets the groups on this tab, in order from left to right. This is the tab's content in XAML.
BackgroundColorGets the colour of the contextual tab set this tab belongs to.
HeaderTextGets or sets the tab's heading in the tab row.
IsContextualTabItemGets whether the tab is on show as one of the ribbon's contextual tabs.
IsCurrentlySelectedGets whether this is the selected tab, whose groups the ribbon is showing.
LogicalChildrenGets the tab's groups, which are its logical children.
RibbonPanelGets the ribbon this tab is on.
SmallImageGets or sets a small picture shown before the heading.
Methods
EndInitCompletes initialisation and applies the tab's template straight away, so that it can be measured before it is first shown.
GetImageStretchGets how a tab's SmallImage is stretched to its space.
OnApplyTemplateCalled when the tab's template is applied.
OnKeyDownWhile the tab has the keyboard focus, selects the previous or next tab on show with Left or Right, and this tab with Space.
OnMouseDoubleClickSwitches the ribbon between showing its commands and showing only its tabs when the tab is double-clicked.
OnMouseLeftButtonDownSelects the tab when it is clicked; on a ribbon showing only its tabs, this also drops the tab's commands down.
SetImageStretchSets how a tab's SmallImage is stretched to its space.
Fields
HeaderTextPropertyIdentifies the HeaderText dependency property.
ImageStretchPropertyIdentifies the ImageStretch attached property. The default is Stretch.Uniform.
IsContextualTabItemPropertyIdentifies the IsContextualTabItem dependency property.
IsCurrentlySelectedPropertyIdentifies the IsCurrentlySelected dependency property.
SmallImagePropertyIdentifies the SmallImage dependency property.

Constructors

BinaryRibbonTabItem

public BinaryRibbonTabItem() : base()

Creates an empty tab; give it a HeaderText and add groups to AvailableRibbonGroups.

Properties

AvailableRibbonGroups

public Collection<BinaryRibbonGroup> AvailableRibbonGroups

Gets the groups on this tab, in order from left to right. This is the tab's content in XAML.

Remarks

When the ribbon runs out of room, the groups give way from the last one in this collection back to the first.

BackgroundColor

public Color BackgroundColor

Gets the colour of the contextual tab set this tab belongs to.

Value
The set's BinaryRibbonControlContextualTabSet.BackgroundColor, or Colors.Transparent for an ordinary tab.

HeaderText

public string HeaderText

Gets or sets the tab's heading in the tab row.

Value
A word or two – "Home", "Insert". The default is an empty string.
Remarks

A heading too long for the tab row ends in an ellipsis; it is also the tab's tool tip, so the whole text can still be read.

IsContextualTabItem

public bool IsContextualTabItem

Gets whether the tab is on show as one of the ribbon's contextual tabs.

Value
true while the tab belongs to the BinaryRibbonBarPanel.ContextualTabSet on show. The default is false.

IsCurrentlySelected

public bool IsCurrentlySelected

Gets whether this is the selected tab, whose groups the ribbon is showing.

Value
The default is false.
Remarks

Set by the ribbon; select a tab through BinaryRibbonBarPanel.SelectedTabItem. A custom tab template can trigger on it to draw the selected look.

LogicalChildren

protected override IEnumerator LogicalChildren

Gets the tab's groups, which are its logical children.

RibbonPanel

public BinaryRibbonBarPanel RibbonPanel

Gets the ribbon this tab is on.

Value
The ribbon, or null until the tab is added to its BinaryRibbonBarPanel.Tabs or to a contextual tab set connected to it. A tab with no ribbon ignores clicks.

SmallImage

public ImageSource SmallImage

Gets or sets a small picture shown before the heading.

Value
Usually 16 by 16 logical pixels. The default is null: no picture, which is how Office draws its tabs.
See also

Methods

EndInit

public override void EndInit()

Completes initialisation and applies the tab's template straight away, so that it can be measured before it is first shown.

Exceptions
System.InvalidOperationException
EndInit was called without a matching FrameworkElement.BeginInit.

GetImageStretch static

public static Stretch GetImageStretch(DependencyObject obj)

Gets how a tab's SmallImage is stretched to its space.

Parameters
obj
The tab.
Returns

The stretch; Stretch.Uniform unless set.

OnApplyTemplate

public override void OnApplyTemplate()

Called when the tab's template is applied.

OnKeyDown

protected override void OnKeyDown(KeyEventArgs e)

While the tab has the keyboard focus, selects the previous or next tab on show with Left or Right, and this tab with Space.

Parameters
e
The data for the event.

OnMouseDoubleClick

protected override void OnMouseDoubleClick(MouseButtonEventArgs e)

Switches the ribbon between showing its commands and showing only its tabs when the tab is double-clicked.

Parameters
e
The data for the event.

OnMouseLeftButtonDown

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)

Selects the tab when it is clicked; on a ribbon showing only its tabs, this also drops the tab's commands down.

Parameters
e
The data for the event.

SetImageStretch static

public static void SetImageStretch(DependencyObject obj, Stretch value)

Sets how a tab's SmallImage is stretched to its space.

Parameters
obj
The tab.
value
The stretch; Stretch.None draws the picture at its own size.

Fields

HeaderTextProperty static

public static readonly DependencyProperty HeaderTextProperty

Identifies the HeaderText dependency property.

ImageStretchProperty static

public static readonly DependencyProperty ImageStretchProperty

Identifies the ImageStretch attached property. The default is Stretch.Uniform.

IsContextualTabItemProperty static

public static DependencyProperty IsContextualTabItemProperty

Identifies the IsContextualTabItem dependency property.

IsCurrentlySelectedProperty static

public static readonly DependencyProperty IsCurrentlySelectedProperty

Identifies the IsCurrentlySelected dependency property.

SmallImageProperty static

public static readonly DependencyProperty SmallImageProperty

Identifies the SmallImage dependency property.