In This Article

BarComboBox Class

Represents a combobox control, for use within a ribbon or toolbar.

[TemplatePart(Name = "PART_DropDownButton", Type = typeof(BarComboBoxDropDownButton))]
[TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))]
public class BarComboBox : BarMenuGalleryHostBase, ISupportsStarSizing
Inheritance:
object Visual UIElement FrameworkElement Control ItemsControl Selector BarGalleryBase BarMenuGalleryHostBase object
Implements:
ISupportsStarSizing

Constructors

BarComboBox()

Initializes an instance of the class.

public BarComboBox()

Properties

CanStopPreviewingOnMouseLeave

Indicates whether the gallery can stop previewing when the mouse leaves the control.

protected override bool CanStopPreviewingOnMouseLeave { get; }

Property Value

bool:

true if the gallery can stop previewing when the mouse leaves the control; otherwise, false.

CornerRadius

The corner radius of the control's border.

public CornerRadius CornerRadius { get; set; }

Property Value

CornerRadius

HasDropShadow

Indicates whether the popup has a drop shadow.

public bool HasDropShadow { get; set; }

Property Value

bool:

true if the popup has a drop shadow; otherwise, false. The default value is true.

HasLabel

Indicates whether the control has a Label available.

public bool HasLabel { get; }

Property Value

bool:

true if the control has a Label available; otherwise, false. The default value is false.

InlineImageSource

The image source for the selected item to display in the combobox, set via the InlineImageSourcePath property.

public ImageSource? InlineImageSource { get; }

Property Value

ImageSource

InlineImageSourcePath

The path to an ImageSource gallery item property, corresponding to optional inline image display.

[Localizability(LocalizationCategory.NeverLocalize)]
public string? InlineImageSourcePath { get; set; }

Property Value

string

IsEditable

Indicates whether the combobox is editable.

public bool IsEditable { get; set; }

Property Value

bool:

true if the combobox is editable; otherwise, false. The default value is false.

IsPopupOpen

Indicates whether the popup is currently open.

public bool IsPopupOpen { get; set; }

Property Value

bool:

true if the popup is currently open; otherwise, false. The default value is false.

IsPreviewEnabledWhenPopupClosed

Indicates whether an editable combobox will preview a gallery item if the item is matched by typed text while the popup is closed.

public bool IsPreviewEnabledWhenPopupClosed { get; set; }

Property Value

bool:

true if an editable combobox will preview a gallery item if the item is matched by typed text while the popup is closed; otherwise, false. The default value is false.

IsReadOnly

Indicates whether the combobox is read-only.

public bool IsReadOnly { get; set; }

Property Value

bool:

true if the combobox is read-only; otherwise, false. The default value is false.

IsStarSizingAllowed

Indicates whether the control can star-size and fill available space when appropriate.

public bool IsStarSizingAllowed { get; set; }

Property Value

bool:

true if star-sizing is allowed; otherwise, false. The default value is false.

IsTextCompletionEnabled

Indicates whether the control will attempt to complete typed text with a matching item.

public bool IsTextCompletionEnabled { get; set; }

Property Value

bool:

true if the control will attempt to complete typed text with a matching item; otherwise, false. The default value is true.

IsUnmatchedTextAllowed

Indicates whether committed Text that is unable to be matched to a gallery item will raise the UnmatchedTextCommand and possibly be allowed.

public bool IsUnmatchedTextAllowed { get; set; }

Property Value

bool:

true if committed Text that is unable to be matched to a gallery item will raise the UnmatchedTextCommand and possibly be allowed; otherwise, false. The default value is true.

See Also

KeyTipText

The key tip text used to access the control.

[Localizability(LocalizationCategory.Label)]
public string? KeyTipText { get; set; }

Property Value

string

MaxPopupHeight

The maximum popup height.

public double MaxPopupHeight { get; set; }

Property Value

double:

The maximum popup height. The default value is Double.PositiveInfinity.

PlaceholderText

The placeholder text to display when the control is empty.

[Localizability(LocalizationCategory.Text)]
public string? PlaceholderText { get; set; }

Property Value

string

PopupAnimation

The PopupAnimation to use in the popup.

public PopupAnimation PopupAnimation { get; set; }

Property Value

PopupAnimation

PopupBackground

The Brush for the popup's background.

public Brush? PopupBackground { get; set; }

Property Value

Brush

PopupBorderBrush

The Brush for the popup's border.

public Brush? PopupBorderBrush { get; set; }

Property Value

Brush

PopupBorderThickness

The Thickness of the popup's border.

public Thickness PopupBorderThickness { get; set; }

Property Value

Thickness

PopupCornerRadius

The CornerRadius of the popup's border.

public CornerRadius PopupCornerRadius { get; set; }

Property Value

CornerRadius

PopupHorizontalOffset

The horizontal offset of the popup.

public double PopupHorizontalOffset { get; set; }

Property Value

double

PopupIndicatorTemplate

The DataTemplate for the popup indicator.

public DataTemplate? PopupIndicatorTemplate { get; set; }

Property Value

DataTemplate

PopupPadding

The Thickness of the popup's padding.

public Thickness PopupPadding { get; set; }

Property Value

Thickness

PopupVerticalOffset

The vertical offset of the popup.

public double PopupVerticalOffset { get; set; }

Property Value

double

RequestedWidth

The requested width of the control.

public double RequestedWidth { get; set; }

Property Value

double:

The requested width of the control. The default value is 110.

ScreenTipFooter

The screen tip footer content.

public object? ScreenTipFooter { get; set; }

Property Value

object

ScreenTipHeader

The screen tip header content.

public object? ScreenTipHeader { get; set; }

Property Value

object

Text

The text to display in the control.

[Localizability(LocalizationCategory.Text)]
public string? Text { get; set; }

Property Value

string

TextPath

The path to a string gallery item property, corresponding to Text display and entry.

[Localizability(LocalizationCategory.NeverLocalize)]
public string? TextPath { get; set; }

Property Value

string

ToolBarItemCollapseBehavior

The ItemCollapseBehavior for the control when in a ribbon using Simplified layout mode.

public ItemCollapseBehavior ToolBarItemCollapseBehavior { get; set; }

Property Value

ItemCollapseBehavior:

The ItemCollapseBehavior for the control when in a ribbon using Simplified layout mode. The default value is Default.

ToolBarItemVariantBehavior

The ItemVariantBehavior for the control when in a toolbar, which also applies when in a ribbon using Simplified layout mode.

public ItemVariantBehavior ToolBarItemVariantBehavior { get; set; }

Property Value

ItemVariantBehavior:

The ItemVariantBehavior for the control when in a toolbar, which also applies when in a ribbon using Simplified layout mode. The default value is AlwaysSmall.

UnmatchedTextCommand

The ICommand to execute when Text is committed that is unable to be matched to a gallery item or when IsTextSearchEnabled is false.

public ICommand? UnmatchedTextCommand { get; set; }

Property Value

ICommand:

The ICommand to execute when Text is committed that is unable to be matched to a gallery item or when IsTextSearchEnabled is false.

Remarks

This command is only used when the IsUnmatchedTextAllowed property is true. The unmatched text string is passed as a command parameter.

When the command is null or CanExecute(object) returns true, the text will be committed; otherwise, it will not be committed.

See Also

VariantSize

The VariantSize currently assigned to the control.

public VariantSize VariantSize { get; set; }

Property Value

VariantSize

Remarks

This property should only be manually set when the control is standalone, and not hosted by a bar control.

Methods

MeasureOverride(Size)

Called to remeasure a control.

protected override Size MeasureOverride(Size constraint)
Parameter Type Description
constraint Size

The maximum size that the method can return.

Returns

Size:

The size of the control, up to the maximum specified by constraint.

OnApplyTemplate()

When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().

public override void OnApplyTemplate()

OnCreateAutomationPeer()

Returns class-specific AutomationPeer implementations for the Windows Presentation Foundation (WPF) infrastructure.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

The type-specific AutomationPeer implementation.

OnGotKeyboardFocus(KeyboardFocusChangedEventArgs)

Invoked when an unhandled System.Windows.Input.Keyboard.GotKeyboardFocus attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

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

The KeyboardFocusChangedEventArgs that contains the event data.

OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs)

Called when the IsKeyboardFocusWithin property has changed.

protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data.

OnKeyDown(KeyEventArgs)

Invoked when the KeyDown event is received.

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

Information about the event.

OnKeyTipInvoked(KeyTipInvokedEventArgs)

Occurs when the control's key tip is invoked.

protected virtual void OnKeyTipInvoked(KeyTipInvokedEventArgs e)
Parameter Type Description
e KeyTipInvokedEventArgs

The KeyTipInvokedEventArgs containing data related to this event.

OnKeyTipOpening(KeyTipOpeningEventArgs)

Occurs when the control's key tip is opening.

protected virtual void OnKeyTipOpening(KeyTipOpeningEventArgs e)
Parameter Type Description
e KeyTipOpeningEventArgs

The KeyTipOpeningEventArgs containing data related to this event.

OnLostKeyboardFocus(KeyboardFocusChangedEventArgs)

Invoked when an unhandled System.Windows.Input.Keyboard.LostKeyboardFocus attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

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

The KeyboardFocusChangedEventArgs that contains event data.

OnPopupClosed(RoutedEventArgs)

Occurs when the IsPopupOpen property changes to false.

protected virtual void OnPopupClosed(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

Remarks

This method has no default implementation. Because an intermediate class in the inheritance might implement this method, we recommend that you call the base implementation in your implementation.

OnPopupOpened(RoutedEventArgs)

Occurs when the IsPopupOpen property changes to true.

protected virtual void OnPopupOpened(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

Remarks

This method has no default implementation. Because an intermediate class in the inheritance might implement this method, we recommend that you call the base implementation in your implementation.

OnPopupOpening(CancelRoutedEventArgs)

Occurs before the IsPopupOpen property changes to true.

protected virtual void OnPopupOpening(CancelRoutedEventArgs e)
Parameter Type Description
e CancelRoutedEventArgs

The event data.

Remarks

This method has no default implementation. Because an intermediate class in the inheritance might implement this method, we recommend that you call the base implementation in your implementation.

OnPreviewKeyDown(KeyEventArgs)

Invoked when an unhandled System.Windows.Input.Keyboard.PreviewKeyDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

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

The KeyEventArgs that contains the event data.

OnSelectedItemPropertyChanged(object?, PropertyChangedEventArgs)

Occurs when the value of a property on a currently selected item is changed.

protected virtual void OnSelectedItemPropertyChanged(object? sender, PropertyChangedEventArgs e)
Parameter Type Description
sender object

The sender of the event.

e PropertyChangedEventArgs

The event data.

OnSelectionChanged(SelectionChangedEventArgs)

Called when the selection changes.

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

The event data.

OnTextCommitted(RoutedEventArgs)

Occurs after text is successfully committed, such as by pressing Enter.

protected virtual void OnTextCommitted(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

OnTextInput(TextCompositionEventArgs)

Invoked when the TextInput event is received.

protected override void OnTextInput(TextCompositionEventArgs e)
Parameter Type Description
e TextCompositionEventArgs

Information about the event.

Events

PopupClosed

Occurs when the IsPopupOpen property changes to false.

public event RoutedEventHandler PopupClosed

Event Type

RoutedEventHandler

PopupOpened

Occurs when the IsPopupOpen property changes to true.

public event RoutedEventHandler PopupOpened

Event Type

RoutedEventHandler

PopupOpening

Occurs before the IsPopupOpen property changes to true.

public event EventHandler<CancelRoutedEventArgs> PopupOpening

Event Type

EventHandler<CancelRoutedEventArgs>

TextCommitted

Occurs after text is successfully committed, such as by pressing Enter.

public event RoutedEventHandler TextCommitted

Event Type

RoutedEventHandler

Fields

CornerRadiusProperty

Defines the CornerRadius property.

public static readonly DependencyProperty CornerRadiusProperty

HasDropShadowProperty

Defines the HasDropShadow property.

public static readonly DependencyProperty HasDropShadowProperty

HasLabelProperty

Defines the HasLabel property.

public static readonly DependencyProperty HasLabelProperty

InlineImageSourcePathProperty

Defines the InlineImageSourcePath property.

public static readonly DependencyProperty InlineImageSourcePathProperty

InlineImageSourceProperty

Defines the InlineImageSource property.

public static readonly DependencyProperty InlineImageSourceProperty

IsEditableProperty

Defines the IsEditable property.

public static readonly DependencyProperty IsEditableProperty

IsPopupOpenProperty

Defines the IsPopupOpen property.

public static readonly DependencyProperty IsPopupOpenProperty

IsPreviewEnabledWhenPopupClosedProperty

Defines the IsPreviewEnabledWhenPopupClosed property.

public static readonly DependencyProperty IsPreviewEnabledWhenPopupClosedProperty

IsReadOnlyProperty

Defines the IsReadOnly property.

public static readonly DependencyProperty IsReadOnlyProperty

IsStarSizingAllowedProperty

Defines the IsStarSizingAllowed property.

public static readonly DependencyProperty IsStarSizingAllowedProperty

IsTextCompletionEnabledProperty

Defines the IsTextCompletionEnabled property.

public static readonly DependencyProperty IsTextCompletionEnabledProperty

IsUnmatchedTextAllowedProperty

Defines the IsUnmatchedTextAllowed property.

public static readonly DependencyProperty IsUnmatchedTextAllowedProperty

KeyTipTextProperty

Defines the KeyTipText property.

public static readonly DependencyProperty KeyTipTextProperty

MaxPopupHeightProperty

Defines the MaxPopupHeight property.

public static readonly DependencyProperty MaxPopupHeightProperty

PlaceholderTextProperty

Defines the PlaceholderText property.

public static readonly DependencyProperty PlaceholderTextProperty

PopupAnimationProperty

Defines the PopupAnimation property.

public static readonly DependencyProperty PopupAnimationProperty

PopupBackgroundProperty

Defines the PopupBackground property.

public static readonly DependencyProperty PopupBackgroundProperty

PopupBorderBrushProperty

Defines the PopupBorderBrush property.

public static readonly DependencyProperty PopupBorderBrushProperty

PopupBorderThicknessProperty

Defines the PopupBorderThickness property.

public static readonly DependencyProperty PopupBorderThicknessProperty

PopupClosedEvent

Defines the PopupClosed routed event.

public static readonly RoutedEvent PopupClosedEvent

PopupCornerRadiusProperty

Defines the PopupCornerRadius property.

public static readonly DependencyProperty PopupCornerRadiusProperty

PopupHorizontalOffsetProperty

Defines the PopupHorizontalOffset property.

public static readonly DependencyProperty PopupHorizontalOffsetProperty

PopupIndicatorTemplateProperty

Defines the PopupIndicatorTemplate property.

public static readonly DependencyProperty PopupIndicatorTemplateProperty

PopupOpenedEvent

Defines the PopupOpened routed event.

public static readonly RoutedEvent PopupOpenedEvent

PopupOpeningEvent

Defines the PopupOpening routed event.

public static readonly RoutedEvent PopupOpeningEvent

PopupPaddingProperty

Defines the PopupPadding property.

public static readonly DependencyProperty PopupPaddingProperty

PopupVerticalOffsetProperty

Defines the PopupVerticalOffset property.

public static readonly DependencyProperty PopupVerticalOffsetProperty

RequestedWidthProperty

Defines the RequestedWidth property.

public static readonly DependencyProperty RequestedWidthProperty

ScreenTipFooterProperty

Defines the ScreenTipFooter property.

public static readonly DependencyProperty ScreenTipFooterProperty

ScreenTipHeaderProperty

Defines the ScreenTipHeader property.

public static readonly DependencyProperty ScreenTipHeaderProperty

TextCommittedEvent

Defines the TextCommitted routed event.

public static readonly RoutedEvent TextCommittedEvent

TextPathProperty

Defines the TextPath property.

public static readonly DependencyProperty TextPathProperty

TextProperty

Defines the Text property.

public static readonly DependencyProperty TextProperty

ToolBarItemCollapseBehaviorProperty

Defines the ToolBarItemCollapseBehavior property.

public static readonly DependencyProperty ToolBarItemCollapseBehaviorProperty

ToolBarItemVariantBehaviorProperty

Defines the ToolBarItemVariantBehavior property.

public static readonly DependencyProperty ToolBarItemVariantBehaviorProperty

UnmatchedTextCommandProperty

Defines the UnmatchedTextCommand property.

public static readonly DependencyProperty UnmatchedTextCommandProperty

VariantSizeProperty

Defines the VariantSize property.

public static readonly DependencyProperty VariantSizeProperty

Inherited Members

Extension Methods