HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonApplicationMenu

BinaryRibbonApplicationMenu

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

The application button at the start of the ribbon's tab row, and the menu it drops down: the file commands – New, Open, Save As, Print, Exit – on the left, and a list such as recent documents on the right.

public class BinaryRibbonApplicationMenu : MenuItem, IBinaryRibbonKeyTipControl, IBinaryRibbonApplicationMenu

Inherits from / implements: MenuItem, IBinaryRibbonKeyTipControl, IBinaryRibbonApplicationMenu

Remarks

Assign it to BinaryRibbonBarPanel.ApplicationMenu. Its items are the commands on the left: use BinaryRibbonApplicationMenuItem for the large-picture entries Office shows, with sub-items for a submenu, and Separator between groups of them; any other item is wrapped in a BinaryRibbonMenuItem. A click on any of them closes the menu.

The right-hand column shows RecentItemsDataSource drawn with RecentItemsTemplate, under HeaderContent – by default a "Recent Documents" heading. FooterContent runs across the foot of the menu. ButtonImage is the picture on the button.

For a menu that opens across the window instead, use BinaryRibbonBackstageApplicationMenu.

Examples

The window's data context has a RecentFiles collection of objects with a FileName property.

<bm:BinaryRibbonApplicationMenu ButtonImage="Images/AppButton.png" RecentItemsDataSource="{Binding RecentFiles}">
    <bm:BinaryRibbonApplicationMenu.RecentItemsTemplate>
        <DataTemplate>
            <ItemsControl ItemsSource="{Binding}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Margin="8,4" Text="{Binding FileName}" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>
    </bm:BinaryRibbonApplicationMenu.RecentItemsTemplate>
    <bm:BinaryRibbonApplicationMenuItem Header="New invoice" Image="Images/New32.png" Click="OnNew" />
    <bm:BinaryRibbonApplicationMenuItem Header="Save As" Image="Images/SaveAs32.png" SubMenuTitleContent="Save a copy of the invoice">
        <bm:BinaryRibbonApplicationMenuItem Header="PDF document" Image="Images/Pdf32.png" Click="OnSaveAsPdf" />
        <bm:BinaryRibbonApplicationMenuItem Header="Excel workbook" Image="Images/Excel32.png" Click="OnSaveAsExcel" />
    </bm:BinaryRibbonApplicationMenuItem>
    <Separator />
    <bm:BinaryRibbonApplicationMenuItem Header="Exit" Image="Images/Exit32.png" Click="OnExit" />
</bm:BinaryRibbonApplicationMenu>

See also

Members at a glance

Constructors
BinaryRibbonApplicationMenuCreates an empty application menu. A click on any of its items closes it.
Properties
ButtonImageGets or sets the picture on the application button.
FooterContentGets or sets what is shown at the foot of the menu – typically an Options and an Exit button, as in Office.
FooterDataTemplateGets or sets the template that draws FooterContent.
HeaderContentGets or sets what is shown at the top of the right-hand column, above the recent items.
HeaderDataTemplateGets or sets the template that draws HeaderContent.
IsOpenGets or sets whether the menu is open.
RecentItemsGets or sets recent items content that the built-in template does not show.
RecentItemsDataSourceGets or sets what the right-hand column lists – usually the recently opened documents.
RecentItemsTemplateGets or sets the template that draws RecentItemsDataSource in the right-hand column.
Methods
GetContainerForItemOverrideCreates the BinaryRibbonMenuItem that an item other than a ribbon menu item or a separator is shown in.
IsItemItsOwnContainerOverrideReports whether an item is shown as it is: a BinaryRibbonMenuItem (an BinaryRibbonApplicationMenuItem among them) or a Separator is; anything else is wrapped.
OnApplyTemplateTakes the template's button, drop-down and recent items column.
OnPopupWindowClosedCalled when the menu's drop-down closes; the base implementation clears IsOpen.
OnPopupWindowOpenCalled when the menu's drop-down opens; the base implementation lines up the copy of the application button drawn over the menu, and sets IsOpen.
Fields
ButtonImagePropertyIdentifies the ButtonImage dependency property.
FooterContentPropertyIdentifies the FooterContent dependency property.
FooterDataTemplatePropertyIdentifies the FooterDataTemplate dependency property.
HeaderContentPropertyIdentifies the HeaderContent dependency property.
HeaderDataTemplatePropertyIdentifies the HeaderDataTemplate dependency property.
IsOpenPropertyIdentifies the IsOpen dependency property.
RecentItemsDataSourcePropertyIdentifies the RecentItemsDataSource dependency property.
RecentItemsPropertyIdentifies the RecentItems dependency property.
RecentItemsTemplatePropertyIdentifies the RecentItemsTemplate dependency property.

Constructors

BinaryRibbonApplicationMenu

public BinaryRibbonApplicationMenu() : base()

Creates an empty application menu. A click on any of its items closes it.

Properties

ButtonImage

public ImageSource ButtonImage

Gets or sets the picture on the application button.

Value
The default is the current skin's application button picture.
Remarks

While BinaryRibbonBuiltInSkinController.Skin is RibbonSkin.Windows7, a picture assigned here is replaced by the built-in Windows 7 one.

FooterContent

public object FooterContent

Gets or sets what is shown at the foot of the menu – typically an Options and an Exit button, as in Office.

Value
The default is null: no footer.
Remarks

The built-in template shows it once, across the foot of the whole menu. It can be an element, such as a panel of buttons, or data with a FooterDataTemplate.

FooterDataTemplate

public DataTemplate FooterDataTemplate

Gets or sets the template that draws FooterContent.

Value
The default is null.

HeaderContent

public object HeaderContent

Gets or sets what is shown at the top of the right-hand column, above the recent items.

Value
The default is null; with the built-in HeaderDataTemplate the column is headed "Recent Documents".

HeaderDataTemplate

public DataTemplate HeaderDataTemplate

Gets or sets the template that draws HeaderContent.

Value
The built-in style supplies one that draws a bold "Recent Documents" heading; replace it to head the column with something else.

IsOpen

public bool IsOpen

Gets or sets whether the menu is open.

Value
The default is false.
Remarks

The application button, its key tip and a click on a menu item change it. Opening or closing the menu also closes the commands of a tabs-only ribbon if they are dropped down (BinaryRibbonBarPanel.CollapseRibbonBarCommand).

RecentItems

public object RecentItems

Gets or sets recent items content that the built-in template does not show.

Value
The default is null.
Remarks

Set RecentItemsDataSource to fill the right-hand column.

RecentItemsDataSource

public object RecentItemsDataSource

Gets or sets what the right-hand column lists – usually the recently opened documents.

Value
Any object, drawn with RecentItemsTemplate; for a list, a collection whose template is an ItemsControl bound to it. The default is null.

RecentItemsTemplate

public DataTemplate RecentItemsTemplate

Gets or sets the template that draws RecentItemsDataSource in the right-hand column.

Value
The default is null, which shows the object as it is (a string as text).

Methods

GetContainerForItemOverride

protected override System.Windows.DependencyObject GetContainerForItemOverride()

Creates the BinaryRibbonMenuItem that an item other than a ribbon menu item or a separator is shown in.

Returns

IsItemItsOwnContainerOverride

protected override bool IsItemItsOwnContainerOverride(object item)

Reports whether an item is shown as it is: a BinaryRibbonMenuItem (an BinaryRibbonApplicationMenuItem among them) or a Separator is; anything else is wrapped.

Parameters
item
The item.
Returns

true for a ribbon menu item or a separator.

OnApplyTemplate

public override void OnApplyTemplate()

Takes the template's button, drop-down and recent items column.

OnPopupWindowClosed

protected virtual void OnPopupWindowClosed(object sender, EventArgs e)

Called when the menu's drop-down closes; the base implementation clears IsOpen.

Parameters
sender
The drop-down.
e
Not used.

OnPopupWindowOpen

protected virtual void OnPopupWindowOpen(object sender, EventArgs e)

Called when the menu's drop-down opens; the base implementation lines up the copy of the application button drawn over the menu, and sets IsOpen.

Parameters
sender
The drop-down.
e
Not used.

Fields

ButtonImageProperty static

public static readonly DependencyProperty ButtonImageProperty

Identifies the ButtonImage dependency property.

FooterContentProperty static

public static readonly DependencyProperty FooterContentProperty

Identifies the FooterContent dependency property.

FooterDataTemplateProperty static

public static readonly DependencyProperty FooterDataTemplateProperty

Identifies the FooterDataTemplate dependency property.

HeaderContentProperty static

public static readonly DependencyProperty HeaderContentProperty

Identifies the HeaderContent dependency property.

HeaderDataTemplateProperty static

public static readonly DependencyProperty HeaderDataTemplateProperty

Identifies the HeaderDataTemplate dependency property.

IsOpenProperty static

public static readonly DependencyProperty IsOpenProperty

Identifies the IsOpen dependency property.

RecentItemsDataSourceProperty static

public static readonly DependencyProperty RecentItemsDataSourceProperty

Identifies the RecentItemsDataSource dependency property.

RecentItemsProperty static

public static readonly DependencyProperty RecentItemsProperty

Identifies the RecentItems dependency property.

RecentItemsTemplateProperty static

public static readonly DependencyProperty RecentItemsTemplateProperty

Identifies the RecentItemsTemplate dependency property.