Class ComboBox
A drop-down list control.
[TemplatePart("PART_Popup", typeof(Popup), IsRequired = true)]
[PseudoClasses(new string[] { ":dropdownopen", ":pressed" })]
public class ComboBox : SelectingItemsControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IChildIndexProvider
- Inheritance
-
ComboBox
- Implements
- Inherited Members
- Extension Methods
Constructors
ComboBox()
public ComboBox()
Fields
HorizontalContentAlignmentProperty
Defines the HorizontalContentAlignment property.
public static readonly StyledProperty<HorizontalAlignment> HorizontalContentAlignmentProperty
Field Value
IsDropDownOpenProperty
Defines the IsDropDownOpen property.
public static readonly StyledProperty<bool> IsDropDownOpenProperty
Field Value
MaxDropDownHeightProperty
Defines the MaxDropDownHeight property.
public static readonly StyledProperty<double> MaxDropDownHeightProperty
Field Value
PlaceholderForegroundProperty
Defines the PlaceholderForeground property.
public static readonly StyledProperty<IBrush?> PlaceholderForegroundProperty
Field Value
PlaceholderTextProperty
Defines the PlaceholderText property.
public static readonly StyledProperty<string?> PlaceholderTextProperty
Field Value
SelectionBoxItemProperty
Defines the SelectionBoxItem property.
public static readonly DirectProperty<ComboBox, object?> SelectionBoxItemProperty
Field Value
SelectionBoxItemTemplateProperty
Defines the SelectionBoxItemTemplate property.
public static readonly StyledProperty<IDataTemplate?> SelectionBoxItemTemplateProperty
Field Value
VerticalContentAlignmentProperty
Defines the VerticalContentAlignment property.
public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty
Field Value
Properties
HorizontalContentAlignment
Gets or sets the horizontal alignment of the content within the control.
public HorizontalAlignment HorizontalContentAlignment { get; set; }
Property Value
IsDropDownOpen
Gets or sets a value indicating whether the dropdown is currently open.
public bool IsDropDownOpen { get; set; }
Property Value
MaxDropDownHeight
Gets or sets the maximum height for the dropdown list.
public double MaxDropDownHeight { get; set; }
Property Value
PlaceholderForeground
Gets or sets the Brush that renders the placeholder text.
public IBrush? PlaceholderForeground { get; set; }
Property Value
PlaceholderText
Gets or sets the PlaceHolder text.
public string? PlaceholderText { get; set; }
Property Value
SelectionBoxItem
Gets or sets the item to display as the control's content.
public object? SelectionBoxItem { get; protected set; }
Property Value
SelectionBoxItemTemplate
Gets or sets the DataTemplate used to display the selected item. This has a higher priority than ItemTemplate if set.
[InheritDataTypeFromItems("ItemsSource")]
public IDataTemplate? SelectionBoxItemTemplate { get; set; }
Property Value
VerticalContentAlignment
Gets or sets the vertical alignment of the content within the control.
public VerticalAlignment VerticalContentAlignment { get; set; }
Property Value
Methods
Clear()
Clears the selection
public void Clear()
CreateContainerForItemOverride(object?, int, object?)
Creates or a container that can be used to display an item.
protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
Parameters
Returns
InvalidateMirrorTransform()
Computes the HasMirrorTransform value according to the FlowDirection and BypassFlowDirectionPolicies
protected override void InvalidateMirrorTransform()
NeedsContainerOverride(object?, int, out object?)
Determines whether the specified item can be its own container.
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
Parameters
item
objectThe item to check.
index
intThe index of the item.
recycleKey
objectWhen the method returns, contains a key that can be used to locate a previously recycled container of the correct type, or null if the item cannot be recycled. If the item is its own container then by definition it cannot be recycled, so
recycleKey
shoud be set to null.
Returns
- bool
true if the item needs a container; otherwise false if the item can itself be used as a container.
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)
Parameters
e
TemplateAppliedEventArgsThe event args.
OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)
Called when the control is added to a rooted visual tree.
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
Parameters
e
VisualTreeAttachmentEventArgsThe event args.
OnCreateAutomationPeer()
Returns a new, type-specific AutomationPeer implementation for the control.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- AutomationPeer
The type-specific AutomationPeer implementation.
OnKeyDown(KeyEventArgs)
Handles directional navigation within the ItemsControl.
protected override void OnKeyDown(KeyEventArgs e)
Parameters
e
KeyEventArgsThe key events.
OnPointerPressed(PointerPressedEventArgs)
Called before the PointerPressed event occurs.
protected override void OnPointerPressed(PointerPressedEventArgs e)
Parameters
e
PointerPressedEventArgsThe event args.
OnPointerReleased(PointerReleasedEventArgs)
Called before the PointerReleased event occurs.
protected override void OnPointerReleased(PointerReleasedEventArgs e)
Parameters
e
PointerReleasedEventArgsThe event args.
OnPointerWheelChanged(PointerWheelEventArgs)
Called before the PointerWheelChanged event occurs.
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
Parameters
e
PointerWheelEventArgsThe event args.
OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
Called when a avalonia property changes on the object.
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
Parameters
change
AvaloniaPropertyChangedEventArgsThe property change details.
Events
DropDownClosed
Occurs after the drop-down (popup) list of the ComboBox closes.
public event EventHandler? DropDownClosed
Event Type
DropDownOpened
Occurs after the drop-down (popup) list of the ComboBox opens.
public event EventHandler? DropDownOpened