HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonControlContextualTabSet

BinaryRibbonControlContextualTabSet

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

A set of contextual tabs: extra tabs at the end of the ribbon's tab row, under a coloured title, that are on show only while the user works on one kind of thing – a picture, a table, a chart.

public class BinaryRibbonControlContextualTabSet : Control, IBinaryRibbonComponent, IBinaryRibbonKeyTipControl

Inherits from / implements: Control, IBinaryRibbonComponent, IBinaryRibbonKeyTipControl

Remarks

Put the tabs in TabItems, give the set a TitleText such as "Picture Tools" and a BackgroundColor, and keep it ready, for example as a resource. When the user selects the kind of thing the tabs act on, assign the set to BinaryRibbonBarPanel.ContextualTabSet; when they move away, set that back to null. The ribbon shows one set at a time.

The tabs work like any other: they are selected, carry key tips and give way to the window's width in the same way. Adding a set to BinaryRibbonBarPanel.ContextualTabSets connects it to the ribbon without showing it.

Examples

A Picture Tools set kept as a window resource and shown while a picture is selected.

<bm:BinaryRibbonWindow.Resources>
    <bm:BinaryRibbonControlContextualTabSet x:Key="PictureTools" TitleText="Picture Tools" BackgroundColor="#FFE8A33D">
        <bm:BinaryRibbonTabItem HeaderText="Format">
            <bm:BinaryRibbonGroup TitleText="Size">
                <bm:BinaryRibbonButton Content="Crop" LargeImage="Images/Crop32.png" Click="OnCrop" />
            </bm:BinaryRibbonGroup>
        </bm:BinaryRibbonTabItem>
    </bm:BinaryRibbonControlContextualTabSet>
</bm:BinaryRibbonWindow.Resources>
private void OnSelectionChanged(object sender, RoutedEventArgs e)
{
    ribbon.ContextualTabSet = editor.SelectedObject is InvoiceLogo
        ? (BinaryRibbonControlContextualTabSet)FindResource("PictureTools")
        : null;
}

See also

Members at a glance

Properties
BackgroundColorGets or sets the colour of the band behind the set's title, which fades out towards the top.
BinaryRibbonTagGets or sets any object the application wants to keep with the set.
IsCurrentlySelectedGets whether the set is the one on show on its ribbon.
RibbonBarPanelGets the ribbon the set is connected to.
TabItemsGets the set's tabs, in order. This is the set's content in XAML.
TitleTextGets or sets the title shown above the set's tabs, such as "Picture Tools" or "Table Design".
Methods
OnTabItemCollectionChangedCalled when TabItems changes; the base implementation connects each added tab to this set and its ribbon, and disconnects each removed one.
Fields
BackgroundColorPropertyIdentifies the BackgroundColor dependency property.
TitleTextPropertyIdentifies the TitleText dependency property.

Properties

BackgroundColor

public Color BackgroundColor

Gets or sets the colour of the band behind the set's title, which fades out towards the top.

Value
The default is Colors.Gold, from the built-in style.

BinaryRibbonTag

public object BinaryRibbonTag

Gets or sets any object the application wants to keep with the set.

Value
The default is null. The ribbon never reads it.

IsCurrentlySelected

public bool IsCurrentlySelected

Gets whether the set is the one on show on its ribbon.

Value
true while assigned to BinaryRibbonBarPanel.ContextualTabSet. The default is false.

RibbonBarPanel

public BinaryRibbonBarPanel RibbonBarPanel

Gets the ribbon the set is connected to.

Value
The ribbon, once the set is assigned to its BinaryRibbonBarPanel.ContextualTabSet or added to its BinaryRibbonBarPanel.ContextualTabSets; otherwise null.

TabItems

public Collection<BinaryRibbonTabItem> TabItems

Gets the set's tabs, in order. This is the set's content in XAML.

TitleText

public string TitleText

Gets or sets the title shown above the set's tabs, such as "Picture Tools" or "Table Design".

Value
The default is an empty string.

Methods

OnTabItemCollectionChanged

protected virtual void OnTabItemCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

Called when TabItems changes; the base implementation connects each added tab to this set and its ribbon, and disconnects each removed one.

Parameters
sender
The collection.
e
The tabs added or removed.

Fields

BackgroundColorProperty static

public static readonly DependencyProperty BackgroundColorProperty

Identifies the BackgroundColor dependency property.

TitleTextProperty static

public static readonly DependencyProperty TitleTextProperty

Identifies the TitleText dependency property.