In This Article

FontSizeComboBox

The FontSizeComboBox class provides an implementation of a ComboBox that allows for selection of a font size. The font size list is automatically populated.

Note

See the Control Basics topic for many implementation details that are common to the built-in controls such as this one.

Variants

This control supports numerous UI styles (called variants) based on its Context and VariantSize property settings.

Context Variant Size Sample UI
MenuItem (all) Screenshot
(any other) Medium (when in StackPanel) Screenshot
(any other) (any other) Screenshot

Capabilities

The following table gives an overview of the capabilities of the control.

Item Details
Supports tall size (fills height of Group) No. When in the ribbon, it should be placed in a StackPanel that is in a Medium variant or smaller.
Supports normal size Yes.
Supports use in a Menu Yes.
Base class ComboBox.
Child items Yes. The items collection inherits from the native WPF ComboBox class and data binding to ItemsSource is fully supported.
Has popup Yes. The items are displayed in the popup.
Key tip access Yes. Set via the KeyTipAccessText property.
Is key tip scope No.
Click event trigger When the Enter key is pressed while in the control, when a new ComboBox selection is made, or when the control loses focus and the value is changed.
Supports use outside of Ribbon Yes.
Supports commands Yes.
Supports ICheckableCommandParameter No.
Supports IValueCommandParameter Yes. Controls the selected value of the ComboBox and supports live preview.
Default CommandParameter DoubleValueCommandParameter.

Managing the Selected Value

This control is designed to use the WPF command model to maintain the selected value of the control. By default, an DoubleValueCommandParameter is assigned as the CommandParameter of the control.

See the Interaction with Value Controls topic for detailed information on using this command parameter to manage the control's value and support live preview.

Layout on the Ribbon and in Menus

It is recommended that when a ComboBox is used in the ribbon that a specific Width be set. When used within a StackPanel, controls such as ComboBox (that don't draw labels inside their bounds like Button controls do) will be lined up and stacked vertically and their optional labels and images will be drawn to the left of them.

When used in a Menu, a MinWidth should be set on the ComboBox. Since the left edge of controls like ComboBox will vary based on the width of its Label, setting a MinWidth ensures that the ComboBox itself will be at least a certain appropriate width and can grow as needed to fill the width of the menu.

Working with the FontSizeComboBox

The ribbon FontSizeComboBox indirectly inherits the native WPF ComboBox control, so anything you can do in the native WPF ComboBox you can do in the ribbon FontSizeComboBox.

Please see the MSDN documentation on the native WPF ComboBox for more details on its capabilities.

You can also use the SelectedValue property to get/set the actual selected Double value. Set the control's value manually like this:

myFontSizeComboBox.SelectedValue = 12.0;

Sample XAML

This code shows how to prototype this control in XAML-only:

<ribbon:ComboBox MinWidth="40" Label="Font Size" KeyTipAccessText="FS" />

This code shows how to prototype this control in XAML but by also using a ribbon command to set up its user interface:

<ribbon:FontSizeComboBox MinWidth="40"
	Command="sample:ApplicationCommands.FontSize" KeyTipAccessText="FS" />