HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonSplitButtonControl

BinaryRibbonSplitButtonControl

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

A ribbon button in two parts: the main part runs a default command at once, and the arrow part holds a drop-down of alternatives – Office's Paste, Undo or Insert Date buttons.

public class BinaryRibbonSplitButtonControl : BinaryRibbonDropDownButton, IBinaryRibbonKeyTipControl

Inherits from / implements: BinaryRibbonDropDownButton, IBinaryRibbonKeyTipControl

Remarks

Use it where one choice is by far the most common: "Insert date" with the date formats in the drop-down, "Save" with Save As, "Approve" with Approve with comments.

The main part

A click on the picture and caption raises MenuItem.Click and runs MenuItem.Command, as a plain button would – on the release of the mouse button, or on the press with ClickMode set to Press. It does not open the drop-down. A click also closes any ribbon pop-up the button is in.

The drop-down

The alternatives are the button's ItemsControl.Items – usually BinaryRibbonMenuItem controls – with BinaryRibbonDropDownButton.DropDownHeaderContent and BinaryRibbonDropDownButton.DropDownFooterContent above and below them, exactly as for BinaryRibbonDropDownButton. Enter or Space opens the drop-down from the keyboard, and setting BinaryRibbonDropDownButton.IsDropDownCurrentlyPressed opens it from code.

Size and keyboard

Large, the main part is the picture and the arrow part is the caption beneath it; medium and small, the arrow is a narrow strip at the right. A key tip (BinaryKeyTip.AccessKeyProperty) clicks the main part.

Examples

<ribbon:BinaryRibbonGroup TitleText="Insert"
        xmlns:ribbon="clr-namespace:Binarymission.WPF.Controls.Office;assembly=Binarymission.WPF.Controls.BinaryRibbon">
    <ribbon:BinaryRibbonSplitButtonControl Content="Insert date"
                                           LargeImage="Images/Calendar32.png"
                                           SmallImage="Images/Calendar16.png"
                                           ribbon:BinaryKeyTip.AccessKey="D"
                                           Click="OnInsertToday">
        <ribbon:BinaryRibbonMenuItem Header="09/10/2026"      Click="OnInsertShortDate" />
        <ribbon:BinaryRibbonMenuItem Header="9 October 2026"  Click="OnInsertLongDate" />
        <ribbon:BinaryRibbonMenuItem Header="Date and time"   Click="OnInsertDateTime" />
    </ribbon:BinaryRibbonSplitButtonControl>
</ribbon:BinaryRibbonGroup>
private void OnInsertToday(object sender, RoutedEventArgs e)
{
    // Click bubbles, so the entries' clicks reach this handler too: act only on the button's own.
    if (e.OriginalSource != sender) return;
    letterEditor.CaretPosition.InsertTextInRun(DateTime.Today.ToLongDateString());
}

See also

Members at a glance

Properties
ClickModeGets or sets when a click on the main part counts: on the release of the mouse button, or on the press.
Methods
OnApplyTemplateApplies the new template as BinaryRibbonDropDownButton does, then finds the arrow part (PART_DropDown) and starts handling the mouse on it.
OnMouseLeftButtonDownShows the main part pressed and, with ClickMode set to Press, clicks it.
OnMouseLeftButtonUpReleases the main part and, with ClickMode set to Release, clicks it.
SwitchStateDoes nothing, so that a click on the main part runs its command rather than opening the drop-down.
Fields
ClickModePropertyIdentifies the ClickMode dependency property.

Properties

ClickMode

public ClickMode ClickMode

Gets or sets when a click on the main part counts: on the release of the mouse button, or on the press.

Value
The click mode. The default is Release, as for a standard button.
Remarks

Press runs the command the moment the button is pressed. With Hover the main part never clicks.

Methods

OnApplyTemplate

public override void OnApplyTemplate()

Applies the new template as BinaryRibbonDropDownButton does, then finds the arrow part (PART_DropDown) and starts handling the mouse on it.

OnMouseLeftButtonDown

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)

Shows the main part pressed and, with ClickMode set to Press, clicks it.

Parameters
e
The data for the event.

OnMouseLeftButtonUp

protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)

Releases the main part and, with ClickMode set to Release, clicks it.

Parameters
e
The data for the event.

SwitchState

protected override void SwitchState()

Does nothing, so that a click on the main part runs its command rather than opening the drop-down.

Remarks

BinaryRibbonDropDownButton opens or closes its drop-down here on every click; the split button overrides it to keep the two parts apart.

Fields

ClickModeProperty static

public static readonly DependencyProperty ClickModeProperty

Identifies the ClickMode dependency property.