In This Article

ComboBox Class

Represents a combobox ribbon control.

public class ComboBox : ComboBoxBase, IKeyTipTarget, IVariantControl
Inheritance:
object Visual UIElement FrameworkElement Control ItemsControl Selector ComboBox ComboBoxBase object
Derived:
FontFamilyComboBox FontSizeComboBox
Implements:
IKeyTipTarget IVariantControl

Remarks

For detailed documentation on this control's features and how to use them, please see the ComboBox documentation topic.

Constructors

ComboBox()

Initializes an instance of the ComboBox class.

public ComboBox()

ComboBox(ICommand)

Initializes an instance of the ComboBox class.

public ComboBox(ICommand command)
Parameter Type Description
command ICommand

The ICommand to assign to the button.

Properties

ActiveItem

Gets or sets the item that is currently active (being previewed).

public object ActiveItem { get; }

Property Value

object:

The item that is currently active (being previewed).

IsPreviewEnabled

Gets or sets whether preview notifications are enabled for the items.

public bool IsPreviewEnabled { get; set; }

Property Value

bool:

true if preview command notifications are enabled for the items; otherwise, false. The default value is false.

StaysOpenOnClick

Gets or sets whether the control keeps a parent popup open when it is clicked.

public bool StaysOpenOnClick { get; set; }

Property Value

bool:

true if the parent popup remains open when the control is clicked; otherwise, false.

TextToValueConverter

Gets or sets the TypeConverter used to convert between the typed text in the combobox and the value type constructed in the control's IValueCommandParameter command parameter.

public TypeConverter TextToValueConverter { get; set; }

Property Value

TypeConverter:

The TypeConverter used to convert between the typed text in the combobox and the value type constructed in the control's IValueCommandParameter command parameter.

Methods

CoerceCommandParameter(DependencyObject, object)

Coerces a new CommandParameterProperty value.

protected override object CoerceCommandParameter(DependencyObject obj, object value)
Parameter Type Description
obj DependencyObject

The System.Windows.DependencyObject whose property is changed.

value object

The new value being set.

Returns

object:

The coerced value to set.

ExtractDataItem(object)

Extracts the data item from the container.

protected virtual object ExtractDataItem(object itemContainer)
Parameter Type Description
itemContainer object

The item container.

Returns

object:

The data item.

IsNullValue(object)

Returns whether the specified value should be represented by blank text in the textbox portion of the combobox.

protected virtual bool IsNullValue(object value)
Parameter Type Description
value object

The value to examine.

Returns

bool:

true if the specified value should be represented by blank text in the textbox portion of the combobox; otherwise, false.

OnActiveItemChanged(object, object)

Occurs when the ActiveItem property is changed and raises the ActiveItemChanged event.

protected virtual void OnActiveItemChanged(object oldActiveItem, object newActiveItem)
Parameter Type Description
oldActiveItem object

The old ActiveItem value.

newActiveItem object

The new ActiveItem value.

OnClick(ExecuteRoutedEventArgs)

Called when the control is clicked.

protected override void OnClick(ExecuteRoutedEventArgs e)
Parameter Type Description
e ExecuteRoutedEventArgs

An ExecuteRoutedEventArgs that contains the event data.

OnDropDownClosed(EventArgs)

Occurs when the drop-down is closed.

protected override void OnDropDownClosed(EventArgs e)
Parameter Type Description
e EventArgs

An KeyEventArgs that contains the event data.

OnDropDownOpened(EventArgs)

Occurs when the drop-down is closed.

protected override void OnDropDownOpened(EventArgs e)
Parameter Type Description
e EventArgs

An KeyEventArgs that contains the event data.

OnGotKeyboardFocus(KeyboardFocusChangedEventArgs)

Occurs after the control gains keyboard focus.

protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
Parameter Type Description
e KeyboardFocusChangedEventArgs

A KeyboardFocusChangedEventArgs that contains the event data.

OnKeyDown(KeyEventArgs)

Occurs when a key is pressed while the control has focus.

protected override void OnKeyDown(KeyEventArgs e)
Parameter Type Description
e KeyEventArgs

A KeyEventArgs that contains the event data.

OnLostKeyboardFocus(KeyboardFocusChangedEventArgs)

Occurs after the control loses keyboard focus.

protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
Parameter Type Description
e KeyboardFocusChangedEventArgs

A KeyboardFocusChangedEventArgs that contains the event data.

OnPreviewKeyDown(KeyEventArgs)

Occurs when a key is pressed while the control has focus.

protected override void OnPreviewKeyDown(KeyEventArgs e)
Parameter Type Description
e KeyEventArgs

A KeyEventArgs that contains the event data.

OnSelectionChanged(SelectionChangedEventArgs)

Occurs when a selection is made.

protected override void OnSelectionChanged(SelectionChangedEventArgs e)
Parameter Type Description
e SelectionChangedEventArgs

A SelectionChangedEventArgs that contains the event data.

SetText(string)

Sets the Text property and can optionally perform other operations.

protected override void SetText(string text)
Parameter Type Description
text string

The text.

UpdateCanExecute()

Updates whether the command can execute.

protected override void UpdateCanExecute()

Events

ActiveItemChanged

Occurs when the ActiveItem property is changed.

public event EventHandler<ObjectPropertyChangedRoutedEventArgs> ActiveItemChanged

Event Type

EventHandler<ObjectPropertyChangedRoutedEventArgs>

Fields

ActiveItemChangedEvent

Identifies the ActiveItemChanged routed event. This field is read-only.

public static readonly RoutedEvent ActiveItemChangedEvent

ActiveItemProperty

Identifies the ActiveItem dependency property. This field is read-only.

public static readonly DependencyProperty ActiveItemProperty

IsPreviewEnabledProperty

Identifies the IsPreviewEnabled dependency property. This field is read-only.

public static readonly DependencyProperty IsPreviewEnabledProperty

StaysOpenOnClickProperty

Identifies the StaysOpenOnClick dependency property. This field is read-only.

public static readonly DependencyProperty StaysOpenOnClickProperty

TextToValueConverterProperty

Identifies the TextToValueConverter dependency property. This field is read-only.

public static readonly DependencyProperty TextToValueConverterProperty

Inherited Members