HypernovaDesktop Components · docs
Binarymission
WPF › Ribbon › BinaryRibbonTextBoxControl

BinaryRibbonTextBoxControl

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

A labelled text box for the ribbon: an optional small picture and a caption, then the box – Office's "Height" and "Width" boxes, or a "Find" box.

public class BinaryRibbonTextBoxControl : TextBox, IBinaryRibbonTextBoxControl, IBinaryRibbonKeyTipControl

Inherits from / implements: TextBox, IBinaryRibbonTextBoxControl, IBinaryRibbonKeyTipControl

Remarks

Use it for a short value typed on the ribbon: a page number, a zoom percentage, a customer code. Image and TitleText sit to the left of the box, and ControlContentWidth sets the width of the box itself. When the ribbon draws the control small the caption is hidden, and when its group folds into a drop-down the control is hidden.

Reading the value

The typing happens in a text box inside the control's template, whose text is copied to this control's TextBox.Text when that inner box loses the keyboard focus – not on every keystroke. TextChanged on this control is therefore raised when the user moves on, which suits a value that is committed rather than filtered as it is typed. Setting TextBox.Text in code shows at once.

Keyboard

A key tip (BinaryKeyTip.AccessKeyProperty) puts the focus in the box and selects its text, ready to be typed over.

Examples

<ribbon:BinaryRibbonGroup TitleText="Go to"
        xmlns:ribbon="clr-namespace:Binarymission.WPF.Controls.Office;assembly=Binarymission.WPF.Controls.BinaryRibbon">
    <ribbon:BinaryRibbonTextBoxControl x:Name="invoiceNumberBox"
                                       TitleText="Invoice"
                                       Image="Images/Invoice16.png"
                                       ControlContentWidth="90"
                                       ribbon:BinaryKeyTip.AccessKey="G"
                                       TextChanged="OnInvoiceNumberEntered" />
</ribbon:BinaryRibbonGroup>

See also

Members at a glance

Properties
ControlContentWidthGets or sets the width of the box the user types in, not counting the picture and caption.
ImageGets or sets the small picture to the left of the caption.
TitleTextGets or sets the caption to the left of the box – "Invoice", "Zoom", "Page".
Methods
OnApplyTemplateApplies the new template, then finds the inner text box (PART_TextBox) that the key tip puts the focus in.
Fields
ControlContentWidthPropertyIdentifies the ControlContentWidth dependency property.
ImagePropertyIdentifies the Image dependency property.
TitleTextPropertyIdentifies the TitleText dependency property.

Properties

ControlContentWidth

public double ControlContentWidth

Gets or sets the width of the box the user types in, not counting the picture and caption.

Value
The width in device-independent units (1/96 inch). The default is NaN, which sizes the box to its text, so it grows as the user types.
Remarks

Set it so that the box keeps one width and boxes in a column line up. FrameworkElement.Width is the width of the whole control.

Image

public ImageSource Image

Gets or sets the small picture to the left of the caption.

Value
The picture, drawn 16 x 16 device-independent units. The default is null, which leaves no gap for one.

TitleText

public string TitleText

Gets or sets the caption to the left of the box – "Invoice", "Zoom", "Page".

Value
The caption. The default is an empty string, which shows no caption.
Remarks

The caption is hidden while the ribbon draws the control at BinaryRibbonControlSize.Small.

Methods

OnApplyTemplate

public override void OnApplyTemplate()

Applies the new template, then finds the inner text box (PART_TextBox) that the key tip puts the focus in.

Fields

ControlContentWidthProperty static

public static readonly DependencyProperty ControlContentWidthProperty

Identifies the ControlContentWidth dependency property.

ImageProperty static

public static readonly DependencyProperty ImageProperty

Identifies the Image dependency property.

TitleTextProperty static

public static readonly DependencyProperty TitleTextProperty

Identifies the TitleText dependency property.