BinaryKeyTip
Key tips: the letters shown over ribbon commands when the user presses Alt, so that every command can be reached from the keyboard.
public class BinaryKeyTip : Control
Inherits from / implements: Control
Remarks
Giving a control a key tip
Set the AccessKey attached property (SetAccessKey) on the tabs, the
application button, the quick access toolbar's commands and the commands in the groups – any element
in a BinaryRibbonWindow. A key tip is one or more letters; with several,
typing the first narrows the tips on show to those that start with it.
Levels
Alt or F10 shows the first level: the key tips nearest the window, typically the tabs and the
application button. Typing one does what the control stands for
(IBinaryRibbonKeyTipControl) and then shows the key tips inside it – a tab's commands,
a menu's items. Escape goes back a level; any other key, a click anywhere in the window, moving the
window or switching away takes them all down. With SetDeferOrDisable off, the key
tips inside a control show at the same level as its own and nothing follows it. Hidden and disabled
elements get no key tip.
Appearance
A tip sits where Office puts it – centred under a tab or a large command, over the picture of
a small one – unless SetXOffset and SetYOffset say otherwise, and is
always kept within its group and the window. SetTipBackground and
SetTipForeground colour it, or ChangeColorForAccessTips for many at
once.
Examples
<bm:BinaryRibbonTabItem HeaderText="Home" bm:BinaryKeyTip.AccessKey="H">
<bm:BinaryRibbonGroup TitleText="Invoice">
<bm:BinaryRibbonButton Content="New" LargeImage="Images/NewInvoice32.png"
bm:BinaryKeyTip.AccessKey="N" Click="OnNewInvoice" />
<bm:BinaryRibbonButton Content="Duplicate" LargeImage="Images/Duplicate32.png"
bm:BinaryKeyTip.AccessKey="DU" Click="OnDuplicateInvoice" />
<bm:BinaryRibbonButton Content="Delete" LargeImage="Images/Delete32.png"
bm:BinaryKeyTip.AccessKey="DE" Click="OnDeleteInvoice" />
</bm:BinaryRibbonGroup>
</bm:BinaryRibbonTabItem>Alt, then H, shows N, DU and DE over the Home tab's commands; D narrows them to DU and DE.
See also
Members at a glance
| Properties | |
|---|---|
AreKeyTipsShown | Gets whether any key tips are on screen. |
| Methods | |
ChangeColorForAccessTips | Colours the key tips of many elements at once: those inside an element, down to the second level. |
GetAccessKey | Gets the letters of an element's key tip. |
GetDeferOrDisable | Gets whether the key tips inside an element wait until its own key tip has been typed. |
GetTipBackground | Gets the background of an element's key tip. |
GetTipForeground | Gets the colour of the letters in an element's key tip. |
GetXOffset | Gets where an element's key tip is placed across the element. |
GetYOffset | Gets where an element's key tip is placed down the element. |
HideKeyTips | Takes down any key tips that are showing, at every level, as a click in the window does. |
SetAccessKey | Gives an element a key tip: the letters the user types, after Alt, to use it. |
SetDeferOrDisable | Sets whether the key tips inside an element wait until its own key tip has been typed. |
SetTipBackground | Sets the background of an element's key tip. |
SetTipForeground | Sets the colour of the letters in an element's key tip. |
SetXOffset | Sets where an element's key tip is placed across the element. |
SetYOffset | Sets where an element's key tip is placed down the element. |
ShowKeyTips | Shows the first level of key tips on a window, as pressing Alt does. |
| Fields | |
AccessKeyProperty | Identifies the AccessKey attached property. |
DeferOrDisableProperty | Identifies the DeferOrDisable attached property. The default is true. |
TipBackgroundProperty | Identifies the TipBackground attached property. The default is InfoBrush. |
TipForegroundProperty | Identifies the TipForeground attached property. The default is WindowTextBrush. |
XOffsetProperty | Identifies the XOffset attached property. The default is NaN. |
YOffsetProperty | Identifies the YOffset attached property. The default is NaN. |
Properties
AreKeyTipsShown static
Gets whether any key tips are on screen.
Methods
ChangeColorForAccessTips static
Colours the key tips of many elements at once: those inside an element, down to the second level.
Parameters
fe- The element to start from – a window, a ribbon, a tab.
desiredBrush- The brush to use.
changeTargetProperty- Whether
desiredBrushis for the background or the letters.
Remarks
Sets the brush on the nearest elements inside fe that have a key tip, and on the
nearest ones inside each of those – for a ribbon, its tabs and their commands. Elements added later
keep their own colours.
Example
BinaryKeyTip.ChangeColorForAccessTips(ribbon, Brushes.Black, BinaryKeyTip.BrushChangeTargetProperty.Background);
BinaryKeyTip.ChangeColorForAccessTips(ribbon, Brushes.White, BinaryKeyTip.BrushChangeTargetProperty.Foreground);GetAccessKey static
Gets the letters of an element's key tip.
Parameters
obj- The element.
Returns
The letters, or null (the default) when the element has no key tip.
GetDeferOrDisable static
Gets whether the key tips inside an element wait until its own key tip has been typed.
Parameters
obj- The element.
Returns
The setting; true unless set.
GetTipBackground static
Gets the background of an element's key tip.
Parameters
obj- The element with the key tip.
Returns
The brush; InfoBrush unless set.
GetTipForeground static
Gets the colour of the letters in an element's key tip.
Parameters
obj- The element with the key tip.
Returns
The brush; WindowTextBrush unless set.
GetXOffset static
Gets where an element's key tip is placed across the element.
Parameters
obj- The element.
Returns
The offset in logical pixels, or NaN (the default) for Office's
placement.
GetYOffset static
Gets where an element's key tip is placed down the element.
Parameters
obj- The element.
Returns
The offset in logical pixels, or NaN (the default) for Office's
placement.
HideKeyTips static
Takes down any key tips that are showing, at every level, as a click in the window does.
SetAccessKey static
Gives an element a key tip: the letters the user types, after Alt, to use it.
Parameters
obj- The element.
value- One or more letters, matched without regard to case; unique among the key
tips shown at the same level.
nullremoves the key tip.
SetDeferOrDisable static
Sets whether the key tips inside an element wait until its own key tip has been typed.
Parameters
obj- The element.
valuetrue(the default) to show the key tips inside the element as the next level, once its own has been typed – as a tab's commands follow the tab.falseto show them at the same level as the element's own, and to take all key tips down once the element's has been typed.
SetTipBackground static
Sets the background of an element's key tip.
Parameters
obj- The element with the key tip.
value- The brush;
nullusesInfoBrush.
Example
<bm:BinaryRibbonButton Content="Approve" LargeImage="Images/Approve32.png" bm:BinaryKeyTip.AccessKey="A"
bm:BinaryKeyTip.TipBackground="#FF2B579A" bm:BinaryKeyTip.TipForeground="White" />SetTipForeground static
Sets the colour of the letters in an element's key tip.
Parameters
obj- The element with the key tip.
value- The brush;
nulldraws the letters inInfoTextBrush.
SetXOffset static
Sets where an element's key tip is placed across the element.
Parameters
obj- The element.
value- The left edge of the tip, in logical pixels from the element's leading edge; a
negative value counts back from its trailing edge.
NaNrestores Office's placement.
Remarks
The tip is moved inwards if it would otherwise be cut off by the group or the window.
SetYOffset static
Sets where an element's key tip is placed down the element.
Parameters
obj- The element.
value- The top edge of the tip, in logical pixels from the element's top; a negative value
counts up from its bottom.
NaNrestores Office's placement.
Remarks
The tip is moved inwards if it would otherwise be cut off by the group or the window.
ShowKeyTips static
Shows the first level of key tips on a window, as pressing Alt does.
Parameters
window- The window whose key tips to show. Nothing happens when it is
null.
Remarks
For an application that offers its own way into keyboard navigation – a help overlay, an accessibility command – and for automated tests, which cannot press Alt on a window of their own process. Key tips already showing are taken down first. Typing a key tip afterwards works exactly as it does after Alt.
Fields
AccessKeyProperty static
Identifies the AccessKey attached property.
DeferOrDisableProperty static
Identifies the DeferOrDisable attached property. The default is true.
TipBackgroundProperty static
Identifies the TipBackground attached property. The default is InfoBrush.
TipForegroundProperty static
Identifies the TipForeground attached property. The default is WindowTextBrush.
XOffsetProperty static
Identifies the XOffset attached property. The default is NaN.
YOffsetProperty static
Identifies the YOffset attached property. The default is NaN.