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(EmbeddedTextBox))]
[PseudoClasses(new string[] { ":editable" })]
public class BarComboBox : BarMenuGalleryHostBase, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IChildIndexProvider, ICommandSource, ISupportsStarSizing
Inheritance:
object AvaloniaObject Animatable StyledElement Visual Layoutable Interactive InputElement Control TemplatedControl ItemsControl SelectingItemsControl BarGalleryBase BarMenuGalleryHostBase object
Implements:
IDataContextProvider ILogical IThemeVariantHost IResourceHost IResourceNode IStyleHost ISetLogicalParent ISetInheritanceParent IStyleable INamed IInputElement IDataTemplateHost ISetterValue IChildIndexProvider ICommandSource ISupportsStarSizing

Constructors

BarComboBox()

Initializes an instance of the class.

public BarComboBox()

Properties

HasLabel

Whether the control has a Avalonia.Controls.Label available.

public bool HasLabel { get; }

Property Value

bool:

The default value is false.

InlineIcon

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

public object? InlineIcon { get; }

Property Value

object

InlineIconMemberBinding

The Avalonia.Data.IBinding to a gallery item property whose value respresents the image corresponding to optional inline image display.

[AssignBinding]
[InheritDataTypeFromItems("ItemsSource")]
public IBinding? InlineIconMemberBinding { get; set; }

Property Value

IBinding

IsEditable

Whether the combobox is editable.

public bool IsEditable { get; set; }

Property Value

bool:

The default value is false.

IsPopupOpen

Whether the popup is currently open.

public bool IsPopupOpen { get; set; }

Property Value

bool:

The default value is false.

IsPreviewEnabledWhenPopupClosed

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:

The default value is false.

IsReadOnly

Whether the combobox is read-only.

public bool IsReadOnly { get; set; }

Property Value

bool:

The default value is false.

IsStarSizingAllowed

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

public bool IsStarSizingAllowed { get; set; }

Property Value

bool:

The default value is false.

IsTextCompletionEnabled

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

public bool IsTextCompletionEnabled { get; set; }

Property Value

bool:

The default value is true.

IsTextSearchCaseSensitive

Whether case is a condition when searching for items.

public bool IsTextSearchCaseSensitive { get; set; }

Property Value

bool:

The default value is false.

IsUnmatchedTextAllowed

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:

The default value is true.

See Also

KeyTipText

The key tip text used to access the control.

public string? KeyTipText { get; set; }

Property Value

string

MaxPopupHeight

The maximum popup height.

public double MaxPopupHeight { get; set; }

Property Value

double:

The default value is PositiveInfinity.

PlaceholderText

The placeholder text to display when the control is empty.

public string? PlaceholderText { get; set; }

Property Value

string

PopupIndicatorTemplate

The popup indicator content.

public IDataTemplate? PopupIndicatorTemplate { get; set; }

Property Value

IDataTemplate

RequestedWidth

The requested width of the control when using Normal density.

public double RequestedWidth { get; set; }

Property Value

double:

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.

public string? Text { get; set; }

Property Value

string

TextMemberBinding

The Avalonia.Data.IBinding to a string gallery item property, corresponding to Text display and entry.

[AssignBinding]
[InheritDataTypeFromItems("ItemsSource")]
public IBinding? TextMemberBinding { get; set; }

Property Value

IBinding

ToolBarItemCollapseBehavior

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

public ItemCollapseBehavior ToolBarItemCollapseBehavior { get; set; }

Property Value

ItemCollapseBehavior:

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 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 Avalonia.Controls.Primitives.SelectingItemsControl.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 Avalonia.Controls.Primitives.SelectingItemsControl.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. This property should only be manually set when the control is standalone, and not hosted by a bar control.

public VariantSize VariantSize { get; set; }

Property Value

VariantSize

Methods

MeasureOverride(Size)

Measures the control and its child elements as part of a layout pass.

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

Returns

Size:

The desired size for the control.

OnApplyTemplate(TemplateAppliedEventArgs)

Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.

protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameter Type Description
e TemplateAppliedEventArgs

The event args.

OnCreateAutomationPeer()

Returns a new, type-specific Avalonia.Automation.Peers.AutomationPeer implementation for the control.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

The type-specific Avalonia.Automation.Peers.AutomationPeer implementation.

OnGotFocus(GotFocusEventArgs)

Called before the Avalonia.Input.InputElement.GotFocus event occurs.

protected override void OnGotFocus(GotFocusEventArgs e)
Parameter Type Description
e GotFocusEventArgs

The event args.

OnKeyDown(KeyEventArgs)

Handles directional navigation within the Avalonia.Controls.ItemsControl.

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

The key events.

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.

OnPopupClosed(RoutedEventArgs)

Occurs after the IsPopupOpen property changes to false.

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

The Avalonia.Interactivity.RoutedEventArgs that contains the event data.

OnPopupOpened(RoutedEventArgs)

Occurs after the IsPopupOpen property changes to true.

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

The Avalonia.Interactivity.RoutedEventArgs that contains the event data.

OnPopupOpening(CancelRoutedEventArgs)

Occurs before the IsPopupOpen property changes to true.

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

The Avalonia.Interactivity.CancelRoutedEventArgs 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 PropertyChangedEventArgs that contains 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 Avalonia.Interactivity.RoutedEventArgs that contains the event data.

OnTextInput(TextInputEventArgs)

Called before the Avalonia.Input.InputElement.TextInput event occurs.

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

The event args.

Events

PopupClosed

Occurs after the IsPopupOpen property changes to false.

public event EventHandler<RoutedEventArgs>? PopupClosed

Event Type

EventHandler<RoutedEventArgs>

PopupOpened

Occurs after the IsPopupOpen property changes to true.

public event EventHandler<RoutedEventArgs>? PopupOpened

Event Type

EventHandler<RoutedEventArgs>

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 Avalonia.Input.Key.Enter.

public event EventHandler<RoutedEventArgs>? TextCommitted

Event Type

EventHandler<RoutedEventArgs>

Fields

HasLabelProperty

Defines the HasLabel property.

public static readonly StyledProperty<bool> HasLabelProperty

InlineIconMemberBindingProperty

Defines the InlineIconMemberBinding property.

public static readonly StyledProperty<IBinding?> InlineIconMemberBindingProperty

InlineIconProperty

Defines the InlineIcon property.

public static readonly StyledProperty<object?> InlineIconProperty

IsEditableProperty

Defines the IsEditable property.

public static readonly StyledProperty<bool> IsEditableProperty

IsPopupOpenProperty

Defines the IsPopupOpen property.

public static readonly StyledProperty<bool> IsPopupOpenProperty

IsPreviewEnabledWhenPopupClosedProperty

Defines the IsPreviewEnabledWhenPopupClosed property.

public static readonly StyledProperty<bool> IsPreviewEnabledWhenPopupClosedProperty

IsReadOnlyProperty

Defines the IsReadOnly property.

public static readonly StyledProperty<bool> IsReadOnlyProperty

IsStarSizingAllowedProperty

Defines the IsStarSizingAllowed property.

public static readonly StyledProperty<bool> IsStarSizingAllowedProperty

IsTextCompletionEnabledProperty

Defines the IsTextCompletionEnabled property.

public static readonly StyledProperty<bool> IsTextCompletionEnabledProperty

IsTextSearchCaseSensitiveProperty

Defines the IsTextSearchCaseSensitive property.

public static readonly StyledProperty<bool> IsTextSearchCaseSensitiveProperty

IsUnmatchedTextAllowedProperty

Defines the IsUnmatchedTextAllowed property.

public static readonly StyledProperty<bool> IsUnmatchedTextAllowedProperty

KeyTipTextProperty

Defines the KeyTipText property.

public static readonly StyledProperty<string?> KeyTipTextProperty

MaxPopupHeightProperty

Defines the MaxPopupHeight property.

public static readonly StyledProperty<double> MaxPopupHeightProperty

PlaceholderTextProperty

Defines the PlaceholderText property.

public static readonly StyledProperty<string?> PlaceholderTextProperty

PopupClosedEvent

Defines the PopupClosed event.

public static readonly RoutedEvent<RoutedEventArgs> PopupClosedEvent

PopupIndicatorTemplateProperty

Defines the PopupIndicatorTemplate property.

public static readonly StyledProperty<IDataTemplate?> PopupIndicatorTemplateProperty

PopupOpenedEvent

Defines the PopupOpened event.

public static readonly RoutedEvent<RoutedEventArgs> PopupOpenedEvent

PopupOpeningEvent

Defines the PopupOpening event.

public static readonly RoutedEvent<CancelRoutedEventArgs> PopupOpeningEvent

RequestedWidthProperty

Defines the RequestedWidth property.

public static readonly StyledProperty<double> RequestedWidthProperty

ScreenTipFooterProperty

Defines the ScreenTipFooter property.

public static readonly StyledProperty<object?> ScreenTipFooterProperty

ScreenTipHeaderProperty

Defines the ScreenTipHeader property.

public static readonly StyledProperty<object?> ScreenTipHeaderProperty

TextCommittedEvent

Defines the TextCommitted event.

public static readonly RoutedEvent<RoutedEventArgs> TextCommittedEvent

TextMemberBindingProperty

Defines the TextMemberBinding property.

public static readonly StyledProperty<IBinding?> TextMemberBindingProperty

TextProperty

Defines the Text property.

public static readonly StyledProperty<string?> TextProperty

ToolBarItemCollapseBehaviorProperty

Defines the ToolBarItemCollapseBehavior property.

public static readonly StyledProperty<ItemCollapseBehavior> ToolBarItemCollapseBehaviorProperty

ToolBarItemVariantBehaviorProperty

Defines the ToolBarItemVariantBehavior property.

public static readonly StyledProperty<ItemVariantBehavior> ToolBarItemVariantBehaviorProperty

UnmatchedTextCommandProperty

Defines the UnmatchedTextCommand property.

public static readonly StyledProperty<ICommand?> UnmatchedTextCommandProperty

VariantSizeProperty

Defines the VariantSize property.

public static readonly StyledProperty<VariantSize> VariantSizeProperty

Inherited Members

Extension Methods