BinaryRibbonBarPanel
The ribbon: a row of tabs, each holding labelled groups of commands, under the window's title, an application button and a quick access toolbar – the command surface of an Office-style application.
public partial class BinaryRibbonBarPanel : Control
Inherits from / implements: Control
Remarks
Put it at the top of a BinaryRibbonWindow, which draws the caption buttons and
frame around it, as the main menu and toolbar of a document or line-of-business application.
Building a ribbon
Its content is Tabs: each BinaryRibbonTabItem holds
BinaryRibbonGroups, and each group holds commands – BinaryRibbonButton,
BinaryRibbonSplitButtonControl, BinaryRibbonDropDownButton,
BinaryRibbonComboBox, BinaryRibbonGallery and the rest. Add
ApplicationMenu, QuickAccessToolBar and TitleText.
Fitting the width
As the window narrows, the groups give way a step at a time from the last: their commands
shrink – a large picture over the caption, then a small picture beside it, then the picture alone,
as each command allows – and at last the group folds into one button that drops its commands down.
SetMinSize, SetMaxSize and SetResizableSize set a
command's steps. Below 240 logical pixels the tabs and commands are hidden
(IsMinimized).
Showing more or less
DisplayState shows tabs and commands, tabs only (a clicked tab drops its commands
over the document) or neither; Ctrl+F1, a double-click on a tab and the right-click menu switch it.
RibbonLayout picks the classic three-row or the simplified one-line ribbon, and
ContextualTabSet adds tabs for what is selected – a table, a picture – under a
coloured title.
Keyboard, tips and skins
BinaryKeyTip.SetAccessKey gives a command a key tip, shown level by level on Alt
or F10 in a BinaryRibbonWindow; BinaryRibbonScreenTipService.SetScreenTip
gives it a titled screen tip. Users add commands to the quick access toolbar by right-clicking them,
and GetQuickAccessToolBarState keeps their choice for the next run. Colours come from
BinaryRibbonBuiltInSkinController.Skin.
Examples
An invoicing window with an application menu, a quick access toolbar and key tips; its
code-behind class derives from BinaryRibbonWindow.
<bm:BinaryRibbonWindow x:Class="Invoicing.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bm="clr-namespace:Binarymission.WPF.Controls.Office;assembly=Binarymission.WPF.Controls.BinaryRibbon"
Title="Invoicing" Width="1100" Height="700">
<DockPanel>
<bm:BinaryRibbonBarPanel DockPanel.Dock="Top" TitleText="Invoicing - Northwind Traders">
<bm:BinaryRibbonBarPanel.ApplicationMenu>
<bm:BinaryRibbonApplicationMenu bm:BinaryKeyTip.AccessKey="F">
<bm:BinaryRibbonApplicationMenuItem Header="New invoice" Image="Images/NewInvoice32.png" Click="OnNewInvoice" />
<bm:BinaryRibbonApplicationMenuItem Header="Open..." Image="Images/Open32.png" Click="OnOpen" />
<Separator />
<bm:BinaryRibbonApplicationMenuItem Header="Exit" Click="OnExit" />
</bm:BinaryRibbonApplicationMenu>
</bm:BinaryRibbonBarPanel.ApplicationMenu>
<bm:BinaryRibbonBarPanel.QuickAccessToolBar>
<bm:BinaryRibbonQuickAccessToolBar>
<bm:BinaryRibbonButton SmallImage="Images/Save16.png" ToolTip="Save" Click="OnSave" />
<bm:BinaryRibbonButton SmallImage="Images/Undo16.png" ToolTip="Undo" Command="ApplicationCommands.Undo" />
</bm:BinaryRibbonQuickAccessToolBar>
</bm:BinaryRibbonBarPanel.QuickAccessToolBar>
<bm:BinaryRibbonTabItem HeaderText="Home" bm:BinaryKeyTip.AccessKey="H">
<bm:BinaryRibbonGroup TitleText="Invoice" CanShowModalDialog="True" ExecuteModalDialogLauncher="OnInvoiceOptions">
<bm:BinaryRibbonButton Content="New" LargeImage="Images/NewInvoice32.png" bm:BinaryKeyTip.AccessKey="N" Click="OnNewInvoice" />
<bm:BinaryRibbonButton Content="Send" LargeImage="Images/Send32.png" bm:BinaryKeyTip.AccessKey="S" Click="OnSendInvoice" />
</bm:BinaryRibbonGroup>
<bm:BinaryRibbonGroup TitleText="Clipboard">
<bm:BinaryRibbonButton Content="Paste" LargeImage="Images/Paste32.png" Command="ApplicationCommands.Paste" />
<bm:BinaryRibbonButton Content="Cut" SmallImage="Images/Cut16.png" bm:BinaryRibbonBarPanel.MaxSize="Medium" Command="ApplicationCommands.Cut" />
<bm:BinaryRibbonButton Content="Copy" SmallImage="Images/Copy16.png" bm:BinaryRibbonBarPanel.MaxSize="Medium" Command="ApplicationCommands.Copy" />
</bm:BinaryRibbonGroup>
</bm:BinaryRibbonTabItem>
</bm:BinaryRibbonBarPanel>
<DataGrid ItemsSource="{Binding Invoices}" />
</DockPanel>
</bm:BinaryRibbonWindow>See also
Members at a glance
| Constructors | |
|---|---|
BinaryRibbonBarPanel | Creates a ribbon with no tabs, application menu or quick access toolbar. |
| Properties | |
AlignGroupsLeftCommand | Gets the command that scrolls a ribbon too narrow for its groups back to the first group. Raise it
from a control inside the ribbon, or with the ribbon as its CommandTarget. |
AlignGroupsRightCommand | Gets the command that scrolls a ribbon too narrow for its groups on to the last group. |
ApplicationMenu | Gets or sets the application button at the start of the tab row and the menu it opens. |
BackgroundColor | Gets the colour of the contextual tab set the selected tab belongs to. |
CanMinimize | Gets or sets whether only the tab row is shown, with a tab's commands dropped over the document when it is clicked. |
CanUserChangeRibbonLayout | Gets or sets whether the user is offered the choice between the classic and the simplified ribbon. |
CollapseRibbonBarCommand | Gets the command that closes the commands a tabs-only ribbon has dropped over the document, by
setting IsExpanded to false. |
ContextualTabSet | Gets or sets the contextual tab set on show at the end of the tab row – the tabs that belong to what the user has selected, under a coloured title. |
ContextualTabSets | Gets the contextual tab sets this ribbon knows about, whether or not one is on show. |
CurrentlyVisibleTabItems | Gets the tabs on show, ordinary then contextual, leaving out any that are hidden. |
DisplayState | Gets or sets how much of the ribbon is on screen: the tabs and their commands, the tabs alone, or neither. |
IsDisplayStateShortcutEnabled | Gets or sets whether Ctrl+F1, pressed anywhere in the ribbon's window, calls
ToggleDisplayState. |
IsExpanded | Gets or sets whether a tabs-only ribbon has dropped the selected tab's commands over the document. |
IsMenuOpen | Gets or sets a flag the ribbon clears whenever it closes its drop-downs. |
IsMinimized | Gets whether the ribbon is too narrow to show anything but its title, with its tabs, commands and quick access toolbar hidden. |
IsRibbonContextMenuEnabled | Gets or sets whether right-clicking the ribbon offers its own menu: add to or remove from the quick access toolbar, show the toolbar above or below the ribbon, simplified ribbon, and collapse the ribbon. |
IsRibbonControlVisible | Gets or sets whether the tab row and the commands are on show; the title and the quick access toolbar stay either way. |
IsTouchMode | Gets whether the ribbon is laid out for touch: small commands on taller rows, with more space between the columns, as in Office's touch mode. |
LogicalChildren | Gets the application menu, the quick access toolbar and every tab, contextual tabs included. |
QuickAccessToolBar | Gets or sets the quick access toolbar: the small commands kept on show whichever tab is selected. |
RibbonLayout | Gets or sets whether the ribbon lays its commands out in the classic three rows or on the single line of the simplified ribbon. |
SelectedGroups | Gets the groups of the selected tab – the groups the ribbon is showing. |
SelectedTabIndex | Gets or sets the position of the selected tab. |
SelectedTabItem | Gets or sets the tab whose groups are on show. |
Tabs | Gets the ribbon's tabs, in the order they appear. This is the ribbon's content in XAML. |
TitleText | Gets or sets the caption shown in bold in the title row, beside the quick access toolbar. |
ToolbarPlacementLocation | Gets or sets whether the quick access toolbar sits above the tabs or below the ribbon. |
| Methods | |
AddToQuickAccessToolBar | Puts a shortcut to a ribbon command on the quick access toolbar, as the user's "Add to Quick Access Toolbar" does. |
ArrangeOverride | Arranges the ribbon, and sizes the contextual tab set's title to the width of its tabs. |
GetCommandId | Gets the name a ribbon command is saved under in GetQuickAccessToolBarState. |
GetMaxSize | Gets the largest size a command is drawn at. |
GetMinSize | Gets the smallest size a command shrinks to as its group gives way. |
GetQuickAccessSource | Gets the ribbon command a quick access toolbar shortcut stands for. |
GetQuickAccessToolBarState | Describes the quick access toolbar – where it sits and which commands the user put on it – as one string to save with the user's settings. |
GetResizableSize | Gets the sizes a command takes, step by step, as its group gives way. |
GetSize | Gets the size a ribbon command is drawn at. |
IndexOfVisibleTab | Finds a tab's position among the tabs on show. |
OnApplyTemplate | Takes the template's group panels, drop-down and tab container, and puts the tabs into the tab row. |
OnContextualTabSetChanged | Called when ContextualTabSet changes; the base implementation swaps the tabs in the
tab row. |
OnContextualTabSetsChanged | Called when ContextualTabSets changes; the base implementation connects each added set
to this ribbon and disconnects each removed one. |
OnIsBarExpandedChanged | Called when IsExpanded changes; the base implementation opens or closes the drop-down. |
OnLostKeyboardFocus | Clears IsMenuOpen when the keyboard focus leaves the ribbon. |
OnLostMouseCapture | Closes the dropped-down commands of a tabs-only ribbon when the user clicks away from them. |
OnPopupClose | Called when the dropped-down commands of a tabs-only ribbon close. The base implementation clears
IsExpanded and releases the mouse; call it when overriding. |
OnPopupOpen | Called when a tabs-only ribbon drops its commands over the document. The base implementation sizes the groups to the drop-down and captures the mouse; call it when overriding. |
OnPreviewMouseLeftButtonDown | Releases the mouse when the ribbon's own background is clicked. |
OnPreviewMouseRightButtonUp | Opens the ribbon's right-click menu when the right button is released, unless
IsRibbonContextMenuEnabled is off. |
OnSelectedGroupsChangedCallback | Called when SelectedGroups changes, after another tab is selected. The base
implementation does nothing. |
OnSelectedTabIndexChanged | Called when SelectedTabIndex changes; the base implementation updates
BackgroundColor. |
OnTabItemCollectionChanged | Called when Tabs changes; the base implementation connects each added tab to this
ribbon and disconnects each removed one. |
OnVisualParentChanged | Starts following the width of the ribbon's new parent, so that the groups give way or come back as it is resized. |
RemoveFromQuickAccessToolBar | Takes a command off the quick access toolbar. |
SetCommandId | Sets the name a ribbon command is saved under in GetQuickAccessToolBarState. |
SetGroupRenderingAlignment | Called when the groups are scrolled to their start or end, or back to fitting the full width. The base implementation does nothing. |
SetMaxSize | Sets the largest size a command is drawn at, even with room to spare. |
SetMinSize | Sets the smallest size a command shrinks to as its group gives way. |
SetQuickAccessSource | Sets the ribbon command a quick access toolbar shortcut stands for. |
SetQuickAccessToolBarState | Puts the quick access toolbar back as GetQuickAccessToolBarState described it. |
SetResizableSize | Sets the sizes a command takes, step by step, as its group gives way. |
SetSize | Sets the size a ribbon command is drawn at. |
ToggleDisplayState | Switches between showing the commands and showing only the tabs, as Ctrl+F1 and a double-click on a tab do. |
ToggleRibbonLayout | Switches RibbonLayout between the classic and the simplified ribbon. |
VisibleTabFromIndex | Finds the tab at a position among the tabs on show. |
| Events | |
SelectedTabIndexChanged | Occurs when another tab is selected, by the user or through SelectedTabIndex. |
| Fields | |
ApplicationMenuProperty | Identifies the ApplicationMenu dependency property. |
BackgroundColorProperty | Identifies the BackgroundColor dependency property. |
CanMinimizeProperty | Identifies the CanMinimize dependency property. |
CanUserChangeRibbonLayoutProperty | Identifies the CanUserChangeRibbonLayout dependency property. |
CommandIdProperty | Identifies the CommandId attached property. |
ContextualTabSetProperty | Identifies the ContextualTabSet dependency property. |
DisplayStateProperty | Identifies the DisplayState dependency property. |
IsDisplayStateShortcutEnabledProperty | Identifies the IsDisplayStateShortcutEnabled dependency property. |
IsExpandedProperty | Identifies the IsExpanded dependency property. |
IsMenuOpenProperty | Identifies the IsMenuOpen dependency property. |
IsMinimizedProperty | Identifies the IsMinimized dependency property. |
IsRibbonContextMenuEnabledProperty | Identifies the IsRibbonContextMenuEnabled dependency property. |
IsRibbonControlVisibleProperty | Identifies the IsRibbonControlVisible dependency property. |
MaxSizeProperty | Identifies the MaxSize attached property. The default is BinaryRibbonControlSize.Large. |
MinSizeProperty | Identifies the MinSize attached property. The default is BinaryRibbonControlSize.Minimized. |
QuickAccessSourceProperty | Identifies the QuickAccessSource attached property. |
QuickAccessToolBarProperty | Identifies the QuickAccessToolBar dependency property. |
ResizableSizeProperty | Identifies the ResizableSize attached property. |
RibbonLayoutProperty | Identifies the RibbonLayout dependency property. |
SelectedGroupsProperty | Identifies the SelectedGroups dependency property. |
SelectedTabIndexChangedEvent | Identifies the SelectedTabIndexChanged routed event. |
SelectedTabIndexProperty | Identifies the SelectedTabIndex dependency property. |
SizeProperty | Identifies the Size attached property. The default is BinaryRibbonControlSize.Large. |
TitleTextProperty | Identifies the TitleText dependency property. |
ToolbarPlacementLocationProperty | Identifies the ToolbarPlacementLocation dependency property. |
Constructors
BinaryRibbonBarPanel
Creates a ribbon with no tabs, application menu or quick access toolbar.
Properties
AlignGroupsLeftCommand static
Gets the command that scrolls a ribbon too narrow for its groups back to the first group. Raise it
from a control inside the ribbon, or with the ribbon as its CommandTarget.
AlignGroupsRightCommand static
Gets the command that scrolls a ribbon too narrow for its groups on to the last group.
BackgroundColor
Gets the colour of the contextual tab set the selected tab belongs to.
- Value
- That set's
BinaryRibbonControlContextualTabSet.BackgroundColor, orColors.Transparent(the default) while an ordinary tab is selected.
CanMinimize
Gets or sets whether only the tab row is shown, with a tab's commands dropped over the document when it is clicked.
- Value
truefor tabs only. The default isfalse.
Remarks
Kept in step with DisplayState being BinaryRibbonDisplayState.ShowTabsOnly;
prefer DisplayState, which also offers auto-hide. A double-click on a tab toggles it.
CanUserChangeRibbonLayout
Gets or sets whether the user is offered the choice between the classic and the simplified ribbon.
- Value
- The default is
true.
Remarks
When false, neither the ribbon's right-click menu nor the window's ribbon display
options offer the two layouts; RibbonLayout still works from code.
CollapseRibbonBarCommand static
Gets the command that closes the commands a tabs-only ribbon has dropped over the document, by
setting IsExpanded to false.
ContextualTabSet
Gets or sets the contextual tab set on show at the end of the tab row – the tabs that belong to what the user has selected, under a coloured title.
- Value
- The set on show, or
nullfor none. The default isnull.
Remarks
Set it when the user selects what the tabs act on, and clear it when they move away; clearing it while one of its tabs is selected selects the first tab.
ContextualTabSets
Gets the contextual tab sets this ribbon knows about, whether or not one is on show.
Remarks
Adding a set here connects it to the ribbon but does not show it; show one by assigning it to
ContextualTabSet.
CurrentlyVisibleTabItems
Gets the tabs on show, ordinary then contextual, leaving out any that are hidden.
DisplayState
Gets or sets how much of the ribbon is on screen: the tabs and their commands, the tabs alone, or neither.
- Value
- The default is
BinaryRibbonDisplayState.ShowTabsAndCommands.
Remarks
BinaryRibbonDisplayState.ShowTabsAndCommands— The whole ribbon.BinaryRibbonDisplayState.ShowTabsOnly— Only the tab row; clicking a tab drops its commands over the document until a command is used or the user clicks away. SetsCanMinimize.BinaryRibbonDisplayState.AutoHide— Neither tabs nor commands; the title and the quick access toolbar stay. ClearsIsRibbonControlVisible.
The user changes it with Ctrl+F1 (IsDisplayStateShortcutEnabled), a double-click
on a tab, the ribbon's right-click menu and the ribbon display options button of a
BinaryRibbonWindow. The ribbon saves nothing itself: store the value with the user's
other settings to keep it between runs.
Example
<bm:BinaryRibbonBarPanel DisplayState="ShowTabsOnly" IsDisplayStateShortcutEnabled="True" />See also
IsDisplayStateShortcutEnabled
Gets or sets whether Ctrl+F1, pressed anywhere in the ribbon's window, calls
ToggleDisplayState.
- Value
- The default is
true.
Remarks
Set it to false when the application gives Ctrl+F1 a meaning of its own. The key
is heard on the window, so it works while the focus is in the document.
IsExpanded
Gets or sets whether a tabs-only ribbon has dropped the selected tab's commands over the document.
- Value
truewhile the commands are dropped down. The default isfalse.
Remarks
Used while DisplayState is BinaryRibbonDisplayState.ShowTabsOnly:
clicking a tab sets it; a command, a click elsewhere or CollapseRibbonBarCommand clears it.
IsMinimized
Gets whether the ribbon is too narrow to show anything but its title, with its tabs, commands and quick access toolbar hidden.
- Value
truewhile narrower than 240 logical pixels. The default isfalse.
IsRibbonControlVisible
Gets or sets whether the tab row and the commands are on show; the title and the quick access toolbar stay either way.
- Value
- The default is
true.
Remarks
BinaryRibbonDisplayState.AutoHide clears it and the other display states set
it.
IsTouchMode
Gets whether the ribbon is laid out for touch: small commands on taller rows, with more space between the columns, as in Office's touch mode.
- Value
truewhileBinarySkinManager.DensityisBinarySkinDensity.Touch. The default isfalse.
Remarks
The density belongs to the application, not to one ribbon: set
BinarySkinManager.Density and every ribbon on screen lays its groups out again, with
rows of 32 logical pixels instead of 24. An application offering Office's Touch/Mouse Mode command sets it
from there.
Example
// The Touch/Mouse Mode command on the quick access toolbar.
private void OnTouchModeClick(object sender, RoutedEventArgs e)
{
BinarySkinManager.Density = ribbon.IsTouchMode ? BinarySkinDensity.Standard : BinarySkinDensity.Touch;
}LogicalChildren
Gets the application menu, the quick access toolbar and every tab, contextual tabs included.
QuickAccessToolBar
Gets or sets the quick access toolbar: the small commands kept on show whichever tab is selected.
- Value
- The toolbar, or
null(the default) for none. Without one, the right-click menu offers no "Add to Quick Access Toolbar".
RibbonLayout
Gets or sets whether the ribbon lays its commands out in the classic three rows or on the single line of the simplified ribbon.
- Value
- The default is
BinaryRibbonLayout.Classic.
Remarks
In the simplified layout each group is one line of small pictures with captions and has no title; as the window narrows the captions go, and then the group folds into a button whose drop-down shows the commands in the usual rows. Galleries always fold.
Independent of DisplayState: a simplified ribbon can still show only its tabs.
The user switches layouts from the right-click menu and the window's ribbon display options, unless
CanUserChangeRibbonLayout is off. The ribbon saves nothing itself; store the value
with the user's settings to keep it between runs.
See also
SelectedGroups
Gets the groups of the selected tab – the groups the ribbon is showing.
- Value
- The selected tab's
BinaryRibbonTabItem.AvailableRibbonGroups, ornullbefore a tab is selected.
SelectedTabIndex
Gets or sets the position of the selected tab.
- Value
- Zero-based, counting the ordinary
Tabsfirst and then the tabs of theContextualTabSet. The default is 0, the first tab.
Remarks
Each change raises SelectedTabIndexChanged. A position past the last tab, or -1,
selects no tab and shows no groups.
SelectedTabItem
Gets or sets the tab whose groups are on show.
- Value
- The selected tab, ordinary or contextual;
nullwhenSelectedTabIndexpoints past every tab or is -1.
Remarks
Setting it sets SelectedTabIndex; null, or a tab that is not on this
ribbon, sets it to -1 and selects no tab. On a
tabs-only ribbon, setting the tab already selected opens or closes its dropped-down commands, as
clicking it does.
Tabs
Gets the ribbon's tabs, in the order they appear. This is the ribbon's content in XAML.
Remarks
Contextual tabs are not added here but through ContextualTabSet. Add the tabs
before the ribbon's template is applied – in XAML, or before the window is shown.
TitleText
Gets or sets the caption shown in bold in the title row, beside the quick access toolbar.
- Value
- Usually the document or application name, as text. The default is
null: no caption.
Remarks
A BinaryRibbonWindow does not draw its own Window.Title; bind this to
it to show it. A long caption ends in an ellipsis.
ToolbarPlacementLocation
Gets or sets whether the quick access toolbar sits above the tabs or below the ribbon.
- Value
- The default is
QuickAccessToolbarPlacementLocation.Top.
Remarks
The user can move it from the right-click menu. A change is passed on to the toolbar's
BinaryRibbonQuickAccessToolBar.ToolBarPlacementLocation.
Methods
AddToQuickAccessToolBar
Puts a shortcut to a ribbon command on the quick access toolbar, as the user's "Add to Quick Access Toolbar" does.
Parameters
command- The command on the ribbon. Nothing happens when it is
null, is already on the toolbar, or the ribbon has noQuickAccessToolBar.
Remarks
The command stays where it is: the toolbar gets a small BinaryRibbonButton with the
command's small picture (or, failing that, its large one) and its tool tip, whose click raises the command's own click
and runs its ICommand. To keep the toolbar between runs, give the
command a SetCommandId and use GetQuickAccessToolBarState.
Example
ribbon.AddToQuickAccessToolBar(printButton);ArrangeOverride
Arranges the ribbon, and sizes the contextual tab set's title to the width of its tabs.
Parameters
arrangeBounds- The space the ribbon was given.
Returns
The space the ribbon used.
GetCommandId static
Gets the name a ribbon command is saved under in GetQuickAccessToolBarState.
Parameters
element- The command.
Returns
The name, or null when it has none or element is
null.
GetMaxSize static
Gets the largest size a command is drawn at.
Parameters
obj- The command.
Returns
The size; BinaryRibbonControlSize.Large unless set.
GetMinSize static
Gets the smallest size a command shrinks to as its group gives way.
Parameters
obj- The command.
Returns
The size; BinaryRibbonControlSize.Minimized unless set.
GetQuickAccessSource static
Gets the ribbon command a quick access toolbar shortcut stands for.
Parameters
element- The item on the toolbar.
Returns
The command on the ribbon, or null when the item is not a shortcut (or
element is null).
GetQuickAccessToolBarState
Describes the quick access toolbar – where it sits and which commands the user put on it – as one string to save with the user's settings.
Returns
The string to hand back to SetQuickAccessToolBarState on the next run, or an empty
string when the ribbon has no QuickAccessToolBar.
Remarks
Only shortcuts standing for a command with a SetCommandId are written down; items put
on the toolbar directly in XAML are part of the application and are not.
Example
// On closing - QuickAccess is a user setting of type string:
Properties.Settings.Default.QuickAccess = ribbon.GetQuickAccessToolBarState();
Properties.Settings.Default.Save();
// On the next start, once the window is loaded:
ribbon.SetQuickAccessToolBarState(Properties.Settings.Default.QuickAccess);GetResizableSize static
Gets the sizes a command takes, step by step, as its group gives way.
Parameters
obj- The command.
Returns
The sizes, or null (the default) when the group decides.
GetSize static
Gets the size a ribbon command is drawn at.
Parameters
obj- The command.
Returns
The size; BinaryRibbonControlSize.Large unless set.
IndexOfVisibleTab
Finds a tab's position among the tabs on show.
Parameters
tabItem- The tab.
Returns
Its zero-based position in CurrentlyVisibleTabItems, or -1 when it is
null, hidden or not on this ribbon.
OnApplyTemplate
Takes the template's group panels, drop-down and tab container, and puts the tabs into the tab row.
OnContextualTabSetChanged
Called when ContextualTabSet changes; the base implementation swaps the tabs in the
tab row.
Parameters
e- The old and new sets.
OnContextualTabSetsChanged
Called when ContextualTabSets changes; the base implementation connects each added set
to this ribbon and disconnects each removed one.
Parameters
sender- The collection.
e- The sets added or removed.
OnIsBarExpandedChanged
Called when IsExpanded changes; the base implementation opens or closes the drop-down.
Parameters
e- The old and new values.
OnLostKeyboardFocus
Clears IsMenuOpen when the keyboard focus leaves the ribbon.
Parameters
e- The data for the event.
OnLostMouseCapture
Closes the dropped-down commands of a tabs-only ribbon when the user clicks away from them.
Parameters
e- The data for the event.
OnPopupClose
Called when the dropped-down commands of a tabs-only ribbon close. The base implementation clears
IsExpanded and releases the mouse; call it when overriding.
Parameters
sender- The drop-down.
e- Not used.
OnPopupOpen
Called when a tabs-only ribbon drops its commands over the document. The base implementation sizes the groups to the drop-down and captures the mouse; call it when overriding.
Parameters
sender- The drop-down.
e- Not used.
OnPreviewMouseLeftButtonDown
Releases the mouse when the ribbon's own background is clicked.
Parameters
e- The data for the event.
OnPreviewMouseRightButtonUp
Opens the ribbon's right-click menu when the right button is released, unless
IsRibbonContextMenuEnabled is off.
Parameters
e- The data for the event.
Remarks
On the button coming up rather than going down, so that the control under the pointer is not left looking pressed.
OnSelectedGroupsChangedCallback
Called when SelectedGroups changes, after another tab is selected. The base
implementation does nothing.
Parameters
e- The old and new groups.
OnSelectedTabIndexChanged
Called when SelectedTabIndex changes; the base implementation updates
BackgroundColor.
Parameters
e- The old and new positions.
OnTabItemCollectionChanged
Called when Tabs changes; the base implementation connects each added tab to this
ribbon and disconnects each removed one.
Parameters
sender- The collection.
e- The tabs added or removed.
OnVisualParentChanged
Starts following the width of the ribbon's new parent, so that the groups give way or come back as it is resized.
Parameters
oldVisualParent- The previous parent.
RemoveFromQuickAccessToolBar
Takes a command off the quick access toolbar.
Parameters
command- The command on the ribbon, or the toolbar item itself. Every shortcut standing for
it is removed; nothing happens when it is
nullor not on the toolbar.
SetCommandId static
Sets the name a ribbon command is saved under in GetQuickAccessToolBarState.
Parameters
element- The command. Ignored when
null. value- A name unique within the ribbon and the same from one run to the next, such as
"Invoice.Send".
SetGroupRenderingAlignment
Called when the groups are scrolled to their start or end, or back to fitting the full width. The base implementation does nothing.
Parameters
alignment- Where the groups sit after the change.
SetMaxSize static
Sets the largest size a command is drawn at, even with room to spare.
Parameters
obj- The command.
value- The size;
BinaryRibbonControlSize.Mediumstacks a command in rows of three with a small picture and its caption, as Cut, Copy and Format Painter are.
SetMinSize static
Sets the smallest size a command shrinks to as its group gives way.
Parameters
obj- The command.
value- The size;
BinaryRibbonControlSize.Largekeeps it large throughout. Not applied on the simplified ribbon, whose single line has no room for large commands.
SetQuickAccessSource static
Sets the ribbon command a quick access toolbar shortcut stands for.
Parameters
element- The item on the toolbar. Ignored when
null. value- The command on the ribbon.
Remarks
AddToQuickAccessToolBar sets it; set it yourself only on a shortcut you add to the
toolbar by hand, so that the ribbon treats it as that command's shortcut.
SetQuickAccessToolBarState
Puts the quick access toolbar back as GetQuickAccessToolBarState described it.
Parameters
state- The saved string. Nothing happens when it is
nullor empty, or the ribbon has noQuickAccessToolBar.
Remarks
The toolbar's position is restored and a shortcut added for each named command, beside what is already on the toolbar. A name no longer on the ribbon is skipped, and an unreadable position is ignored, so a saved setting that has outlived a command never stops the rest being restored.
SetResizableSize static
Sets the sizes a command takes, step by step, as its group gives way.
Parameters
obj- The command.
value- One size per step, starting with the full-width ribbon; the last applies to every
step after it. In XAML, a comma-separated list of size names or their initials, without spaces:
"L,M,S".
Remarks
When set, SetMinSize and SetMaxSize are not applied, and the
group folds into a single button after as many steps as its longest list.
SetSize static
Sets the size a ribbon command is drawn at.
Parameters
obj- The command.
value- Large (picture over caption), medium (small picture beside caption), small (picture alone) or minimised (hidden).
Remarks
A group sets this on its commands whenever it is resized; for a command in a group use
SetMaxSize, SetMinSize or SetResizableSize.
ToggleDisplayState
Switches between showing the commands and showing only the tabs, as Ctrl+F1 and a double-click on a tab do.
Remarks
From BinaryRibbonDisplayState.ShowTabsAndCommands it goes to
BinaryRibbonDisplayState.ShowTabsOnly; from either other state it brings the whole
ribbon back, so it is always the way back to a ribbon that is out of sight.
ToggleRibbonLayout
Switches RibbonLayout between the classic and the simplified ribbon.
VisibleTabFromIndex
Finds the tab at a position among the tabs on show.
Parameters
index- The zero-based position in
CurrentlyVisibleTabItems.
Returns
The tab, or null when the position is negative or past the last tab.
Events
SelectedTabIndexChanged
Occurs when another tab is selected, by the user or through SelectedTabIndex.
Remarks
A bubbling routed event; read SelectedTabItem for the new tab.
Fields
BackgroundColorProperty static
Identifies the BackgroundColor dependency property.
CanMinimizeProperty static
Identifies the CanMinimize dependency property.
CanUserChangeRibbonLayoutProperty static
Identifies the CanUserChangeRibbonLayout dependency property.
CommandIdProperty static
Identifies the CommandId attached property.
Remarks
A command without one can still be put on the quick access toolbar; it is just not remembered
between runs, because there is nothing to write down. Only commands directly in a group on one of
the ordinary Tabs are found again by SetQuickAccessToolBarState.
Example
<bm:BinaryRibbonButton Content="Send" LargeImage="Images/Send32.png" bm:BinaryRibbonBarPanel.CommandId="Invoice.Send" />ContextualTabSetProperty static
Identifies the ContextualTabSet dependency property.
DisplayStateProperty static
Identifies the DisplayState dependency property.
IsDisplayStateShortcutEnabledProperty static
Identifies the IsDisplayStateShortcutEnabled dependency property.
IsExpandedProperty static
Identifies the IsExpanded dependency property.
IsMinimizedProperty static
Identifies the IsMinimized dependency property.
IsRibbonControlVisibleProperty static
Identifies the IsRibbonControlVisible dependency property.
MaxSizeProperty static
Identifies the MaxSize attached property. The default is BinaryRibbonControlSize.Large.
MinSizeProperty static
Identifies the MinSize attached property. The default is BinaryRibbonControlSize.Minimized.
QuickAccessSourceProperty static
Identifies the QuickAccessSource attached property.
QuickAccessToolBarProperty static
Identifies the QuickAccessToolBar dependency property.
ResizableSizeProperty static
Identifies the ResizableSize attached property.
RibbonLayoutProperty static
Identifies the RibbonLayout dependency property.
SelectedGroupsProperty static
Identifies the SelectedGroups dependency property.
SelectedTabIndexChangedEvent static
Identifies the SelectedTabIndexChanged routed event.
SelectedTabIndexProperty static
Identifies the SelectedTabIndex dependency property.
SizeProperty static
Identifies the Size attached property. The default is BinaryRibbonControlSize.Large.
TitleTextProperty static
Identifies the TitleText dependency property.
ToolbarPlacementLocationProperty static
Identifies the ToolbarPlacementLocation dependency property.