HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonButtonGroup

BinaryRibbonButtonGroup

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

A row of small ribbon buttons joined edge to edge into one rounded strip, like Office's Bold, Italic and Underline or its paragraph alignment buttons.

public class BinaryRibbonButtonGroup : ItemsControl, IBinaryRibbonElementBoundsConfigurable, IBinaryRibbonKeyTipControl

Inherits from / implements: ItemsControl, IBinaryRibbonElementBoundsConfigurable, IBinaryRibbonKeyTipControl

Remarks

Use it for a handful of closely related commands that read best as a set: text formatting, alignment, zoom in and out, the previous and next record.

What goes in it

Put BinaryRibbonButton, BinaryRibbonToggleButtonControl, BinaryRibbonDropDownButton or BinaryRibbonSplitButtonControl controls in ItemsControl.Items. Each is drawn small – picture only, no caption – side by side, the buttons 26 units wide and the drop-down and split buttons 40. The group rounds the outer corners of the first and last button to its own CornerRadius and squares the rest, so the strip reads as one control.

Important

Every item must be one of those ribbon buttons (an IBinaryRibbonContentElementBoundsConfigurable). The group sets each item's corners whenever the items change and does not check, so a plain WPF control, a string, or a data object supplied through ItemsControl.ItemsSource stops it with a NullReferenceException.

Keyboard

A key tip on the group (BinaryKeyTip.AccessKeyProperty) only moves the focus to it; give each button a key tip of its own to make it reachable from the keyboard.

Examples

Bold, italic and underline toggles in a Font group.

<ribbon:BinaryRibbonGroup TitleText="Font"
        xmlns:ribbon="clr-namespace:Binarymission.WPF.Controls.Office;assembly=Binarymission.WPF.Controls.BinaryRibbon">
    <ribbon:BinaryRibbonButtonGroup>
        <ribbon:BinaryRibbonToggleButtonControl SmallImage="Images/Bold16.png"
                                                ribbon:BinaryKeyTip.AccessKey="1"
                                                IsChecked="{Binding SelectionIsBold}" />
        <ribbon:BinaryRibbonToggleButtonControl SmallImage="Images/Italic16.png"
                                                ribbon:BinaryKeyTip.AccessKey="2"
                                                IsChecked="{Binding SelectionIsItalic}" />
        <ribbon:BinaryRibbonToggleButtonControl SmallImage="Images/Underline16.png"
                                                ribbon:BinaryKeyTip.AccessKey="3"
                                                IsChecked="{Binding SelectionIsUnderlined}" />
    </ribbon:BinaryRibbonButtonGroup>
</ribbon:BinaryRibbonGroup>

See also

Members at a glance

Properties
CornerRadiusGets or sets how rounded the two ends of the strip are.
Methods
GetContainerForItemOverrideCreates the container for an item that is not a control of its own, which for this control is a BinaryRibbonButton.
OnItemsChangedRounds the outer corners of the first and last button and squares the rest, after the base handling of a change to the items.
PrepareContainerForItemOverridePrepares a container to show its item, and sets it to the ribbon's small size.
Fields
CornerRadiusPropertyIdentifies the CornerRadius dependency property.

Properties

CornerRadius

public CornerRadius CornerRadius

Gets or sets how rounded the two ends of the strip are.

Value
The corner radius, in device-independent units (1/96 inch). The default is 3 on every corner.
Remarks

The group hands the left-hand corners to its first button and the right-hand corners to its last (both to a button that is alone in the group), and gives the buttons in between square corners. It does this when the items change, so set the radius before adding the buttons.

Methods

GetContainerForItemOverride

protected override DependencyObject GetContainerForItemOverride()

Creates the container for an item that is not a control of its own, which for this control is a BinaryRibbonButton.

Returns

OnItemsChanged

protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

Rounds the outer corners of the first and last button and squares the rest, after the base handling of a change to the items.

Parameters
e
What changed in the items.

PrepareContainerForItemOverride

protected override void PrepareContainerForItemOverride(DependencyObject element, object item)

Prepares a container to show its item, and sets it to the ribbon's small size.

Parameters
element
The container.
item
The item it shows.

Fields

CornerRadiusProperty static

public static readonly DependencyProperty CornerRadiusProperty

Identifies the CornerRadius dependency property.