HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonMenuItem

BinaryRibbonMenuItem

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

A menu entry in the ribbon's style – for the drop-downs of ribbon buttons and for the application menu – with a small picture, a tick when checked, and an arrow that opens a sub-menu.

public class BinaryRibbonMenuItem : MenuItem, IBinaryRibbonKeyTipControl

Inherits from / implements: MenuItem, IBinaryRibbonKeyTipControl

Remarks

It is a WPF MenuItem: the text goes in HeaderedItemsControl.Header, and MenuItem.Click, MenuItem.Command, MenuItem.IsCheckable and MenuItem.IsChecked work as usual. Put it in a BinaryRibbonDropDownButton, a BinaryRibbonSplitButtonControl or a BinaryRibbonApplicationMenu; a click on it closes the drop-down button it is in.

Picture and check mark

Image is drawn 16 x 16 in a column to the left of the text, which is kept even when there is no picture so that the text of every entry lines up. A checked entry is drawn with a highlighted box behind its picture, or behind a tick when it has no picture.

Sub-menus

Entries in ItemsControl.Items make a sub-menu, opened from an arrow on the right of the entry and shown beside it. In a BinaryRibbonApplicationMenu the sub-menu fills the menu's right-hand pane instead, as Office's Save As and Print entries do.

Keyboard

A key tip (BinaryKeyTip.AccessKeyProperty) opens or closes the sub-menu of an entry that has one, and clicks an entry that has not.

Examples

A Print drop-down: a checkable option, and an entry with a sub-menu.

<ribbon:BinaryRibbonDropDownButton Content="Print" LargeImage="Images/Print32.png"
        xmlns:ribbon="clr-namespace:Binarymission.WPF.Controls.Office;assembly=Binarymission.WPF.Controls.BinaryRibbon">
    <ribbon:BinaryRibbonMenuItem Header="Print invoice"  Image="Images/Print16.png" Click="OnPrintInvoice"
                                 ribbon:BinaryKeyTip.AccessKey="P" />
    <ribbon:BinaryRibbonMenuItem Header="Include remittance slip" IsCheckable="True"
                                 IsChecked="{Binding IncludeRemittanceSlip}" />
    <ribbon:BinaryRibbonMenuItem Header="Print labels" Image="Images/Label16.png">
        <ribbon:BinaryRibbonMenuItem Header="Address label"  Click="OnPrintAddressLabel" />
        <ribbon:BinaryRibbonMenuItem Header="Parcel label"   Click="OnPrintParcelLabel" />
    </ribbon:BinaryRibbonMenuItem>
</ribbon:BinaryRibbonDropDownButton>

See also

Members at a glance

Properties
ImageGets or sets the small picture drawn to the left of the entry's text.
Methods
OnApplyTemplateApplies the new template, then finds its PART_Popup sub-menu pop-up and starts listening for it opening and closing.
OnPopupClosedCalled when the sub-menu pop-up closes; marks the sub-menu closed.
OnPopupOpenCalled when the sub-menu pop-up opens. In a BinaryRibbonApplicationMenu, moves and sizes it to fill the menu's right-hand pane; elsewhere it leaves it beside the entry.
OnSubmenuClosedCloses the sub-menu pop-up, after the base handling of the sub-menu closing.
OnSubmenuOpenedOpens the sub-menu pop-up, after the base handling of the sub-menu opening.
Fields
ImagePropertyIdentifies the Image dependency property.

Properties

Image

public ImageSource Image

Gets or sets the small picture drawn to the left of the entry's text.

Value
The picture, drawn 16 x 16 device-independent units. The default is null.
Remarks

Use this rather than MenuItem.Icon, which the ribbon's template does not show. When the entry is checked, a highlighted box is drawn behind the picture.

Methods

OnApplyTemplate

public override void OnApplyTemplate()

Applies the new template, then finds its PART_Popup sub-menu pop-up and starts listening for it opening and closing.

OnPopupClosed

protected virtual void OnPopupClosed(object sender, EventArgs e)

Called when the sub-menu pop-up closes; marks the sub-menu closed.

Parameters
sender
The pop-up.
e
Not used.
Remarks

Call the base method from an override, so that MenuItem.IsSubmenuOpen stays in step.

OnPopupOpen

protected virtual void OnPopupOpen(object sender, EventArgs e)

Called when the sub-menu pop-up opens. In a BinaryRibbonApplicationMenu, moves and sizes it to fill the menu's right-hand pane; elsewhere it leaves it beside the entry.

Parameters
sender
The pop-up.
e
Not used.

OnSubmenuClosed

protected override void OnSubmenuClosed(RoutedEventArgs e)

Closes the sub-menu pop-up, after the base handling of the sub-menu closing.

Parameters
e
The data for the event.

OnSubmenuOpened

protected override void OnSubmenuOpened(RoutedEventArgs e)

Opens the sub-menu pop-up, after the base handling of the sub-menu opening.

Parameters
e
The data for the event.

Fields

ImageProperty static

public static readonly DependencyProperty ImageProperty

Identifies the Image dependency property.