HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryKeyTip

BinaryKeyTip

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

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
AreKeyTipsShownGets whether any key tips are on screen.
Methods
ChangeColorForAccessTipsColours the key tips of many elements at once: those inside an element, down to the second level.
GetAccessKeyGets the letters of an element's key tip.
GetDeferOrDisableGets whether the key tips inside an element wait until its own key tip has been typed.
GetTipBackgroundGets the background of an element's key tip.
GetTipForegroundGets the colour of the letters in an element's key tip.
GetXOffsetGets where an element's key tip is placed across the element.
GetYOffsetGets where an element's key tip is placed down the element.
HideKeyTipsTakes down any key tips that are showing, at every level, as a click in the window does.
SetAccessKeyGives an element a key tip: the letters the user types, after Alt, to use it.
SetDeferOrDisableSets whether the key tips inside an element wait until its own key tip has been typed.
SetTipBackgroundSets the background of an element's key tip.
SetTipForegroundSets the colour of the letters in an element's key tip.
SetXOffsetSets where an element's key tip is placed across the element.
SetYOffsetSets where an element's key tip is placed down the element.
ShowKeyTipsShows the first level of key tips on a window, as pressing Alt does.
Fields
AccessKeyPropertyIdentifies the AccessKey attached property.
DeferOrDisablePropertyIdentifies the DeferOrDisable attached property. The default is true.
TipBackgroundPropertyIdentifies the TipBackground attached property. The default is InfoBrush.
TipForegroundPropertyIdentifies the TipForeground attached property. The default is WindowTextBrush.
XOffsetPropertyIdentifies the XOffset attached property. The default is NaN.
YOffsetPropertyIdentifies the YOffset attached property. The default is NaN.

Properties

AreKeyTipsShown static

public static bool AreKeyTipsShown

Gets whether any key tips are on screen.

Methods

ChangeColorForAccessTips static

public static void ChangeColorForAccessTips(FrameworkElement fe, Brush desiredBrush, BrushChangeTargetProperty changeTargetProperty)

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 desiredBrush is 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

public static string GetAccessKey(DependencyObject obj)

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

public static bool GetDeferOrDisable(DependencyObject obj)

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

public static Brush GetTipBackground(DependencyObject obj)

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

public static Brush GetTipForeground(DependencyObject obj)

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

public static double GetXOffset(DependencyObject obj)

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

public static double GetYOffset(DependencyObject obj)

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

public static void HideKeyTips()

Takes down any key tips that are showing, at every level, as a click in the window does.

SetAccessKey static

public static void SetAccessKey(DependencyObject obj, string value)

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. null removes the key tip.

SetDeferOrDisable static

public static void SetDeferOrDisable(DependencyObject obj, bool value)

Sets whether the key tips inside an element wait until its own key tip has been typed.

Parameters
obj
The element.
value
true (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. false to 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

public static void SetTipBackground(DependencyObject obj, Brush value)

Sets the background of an element's key tip.

Parameters
obj
The element with the key tip.
value
The brush; null uses InfoBrush.
Example
<bm:BinaryRibbonButton Content="Approve" LargeImage="Images/Approve32.png" bm:BinaryKeyTip.AccessKey="A"
                       bm:BinaryKeyTip.TipBackground="#FF2B579A" bm:BinaryKeyTip.TipForeground="White" />

SetTipForeground static

public static void SetTipForeground(DependencyObject obj, Brush value)

Sets the colour of the letters in an element's key tip.

Parameters
obj
The element with the key tip.
value
The brush; null draws the letters in InfoTextBrush.

SetXOffset static

public static void SetXOffset(DependencyObject obj, double value)

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. NaN restores Office's placement.
Remarks

The tip is moved inwards if it would otherwise be cut off by the group or the window.

SetYOffset static

public static void SetYOffset(DependencyObject obj, double value)

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. NaN restores Office's placement.
Remarks

The tip is moved inwards if it would otherwise be cut off by the group or the window.

ShowKeyTips static

public static void ShowKeyTips(Window window)

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

public static readonly DependencyProperty AccessKeyProperty

Identifies the AccessKey attached property.

DeferOrDisableProperty static

public static readonly DependencyProperty DeferOrDisableProperty

Identifies the DeferOrDisable attached property. The default is true.

TipBackgroundProperty static

public static readonly DependencyProperty TipBackgroundProperty

Identifies the TipBackground attached property. The default is InfoBrush.

TipForegroundProperty static

public static readonly DependencyProperty TipForegroundProperty

Identifies the TipForeground attached property. The default is WindowTextBrush.

XOffsetProperty static

public static readonly DependencyProperty XOffsetProperty

Identifies the XOffset attached property. The default is NaN.

YOffsetProperty static

public static readonly DependencyProperty YOffsetProperty

Identifies the YOffset attached property. The default is NaN.