BinaryRibbonSplitButtonControl
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 | |
|---|---|
ClickMode | Gets or sets when a click on the main part counts: on the release of the mouse button, or on the press. |
| Methods | |
OnApplyTemplate | Applies the new template as BinaryRibbonDropDownButton does, then finds the arrow part
(PART_DropDown) and starts handling the mouse on it. |
OnMouseLeftButtonDown | Shows the main part pressed and, with ClickMode set to
Press, clicks it. |
OnMouseLeftButtonUp | Releases the main part and, with ClickMode set to
Release, clicks it. |
SwitchState | Does nothing, so that a click on the main part runs its command rather than opening the drop-down. |
| Fields | |
ClickModeProperty | Identifies the ClickMode dependency property. |
Properties
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
Methods
OnApplyTemplate
Applies the new template as BinaryRibbonDropDownButton does, then finds the arrow part
(PART_DropDown) and starts handling the mouse on it.
OnMouseLeftButtonDown
Parameters
e- The data for the event.
OnMouseLeftButtonUp
Parameters
e- The data for the event.
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
Identifies the ClickMode dependency property.