In This Article

AutoCompleteBox Class

Represents a text control that provides suggestions to end users as they type.

[TemplatePart(Name = "PART_Popup", Type = typeof(Popup))]
[TemplatePart(Name = "PART_Selector", Type = typeof(EmbeddedListBox))]
[TemplatePart(Name = "PART_TextBox", Type = typeof(EmbeddedTextBox))]
[TemplateVisualState(Name = "Normal", GroupName = "CommonStates")]
[TemplateVisualState(Name = "PointerOver", GroupName = "CommonStates")]
[TemplateVisualState(Name = "Focused", GroupName = "CommonStates")]
[TemplateVisualState(Name = "Disabled", GroupName = "CommonStates")]
public class AutoCompleteBox : Control, DUCE.IResource, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IHaveResources, IQueryAmbient
Inheritance:
Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Control Object

Constructors

AutoCompleteBox()

Initializes an instance of the AutoCompleteBox class.

public AutoCompleteBox()

Properties

CanSelectAllOnUpdate

Gets or sets whether the entire text should be selected following a text update, like a suggestion being chosen.

public bool CanSelectAllOnUpdate { get; set; }

Property Value

Boolean:

true if the entire text should be selected following a text update, like a suggestion being chosen; otherwise false. The default value is true.

CharacterCasing

Gets or sets how characters are cased when they are manually entered into the text box.

public CharacterCasing CharacterCasing { get; set; }

Property Value

CharacterCasing:

One of the CharacterCasing values that specifies how manually entered characters are cased. The default value is Normal.

ClearCommand

Gets the ICommand that clears the text value.

public ICommand ClearCommand { get; }

Property Value

ICommand:

The ICommand that clears the text value.

DataFilter

Gets or sets the IDataFilter to use for matching suggested items.

public IDataFilter DataFilter { get; set; }

Property Value

IDataFilter:

The IDataFilter to use for matching suggested items.

DisplayMemberPath

Gets or sets the name of the property that provides each item's text within the suggestion list.

public string DisplayMemberPath { get; set; }

Property Value

String:

The name of the property that provides each item's text within the suggestion list.

FilteredItemsSource

Gets the filtered collection of suggested items to display in the suggestion list.

public IEnumerable FilteredItemsSource { get; }

Property Value

IEnumerable:

The filtered collection of suggested items to display in the suggestion list.

FilterText

Gets the text against which suggested items should be filtered.

protected virtual string FilterText { get; }

Property Value

String:

The text against which suggested items should be filtered.

Remarks

The default implementation of this property returns the Text property value.

HasClearButton

Gets or sets a value indicating whether the control has a clear button when there is text.

public bool HasClearButton { get; set; }

Property Value

Boolean:

true if the control has a clear button when there is text; otherwise false. The default value is false.

Remarks

When the InputMode is ComboBox, the clear button will only be displayed if the control is focused.

HasItems

Gets whether there is at least one suggested item in the suggestion list.

public bool HasItems { get; }

Property Value

Boolean:

true if there is at least one suggested item in the suggestion list; otherwise, false. The default value is false.

HasPopupButton

Gets or sets a value indicating whether the control has a popup button.

public bool HasPopupButton { get; set; }

Property Value

Boolean:

true if the control has a popup button; otherwise false. The default value is true.

InputMode

Gets or sets the input mode.

public AutoCompleteBoxInputMode InputMode { get; set; }

Property Value

AutoCompleteBoxInputMode:

An AutoCompleteBoxInputMode that indicates the input mode. The default value is Search.

IsClearButtonVisible

Gets whether the clear button is visible.

public bool IsClearButtonVisible { get; }

Property Value

Boolean:

true if the clear button is visible; otherwise false. The default value is false.

Remarks

The HasClearButton property and other state-related info determines whether the clear button is visible.

IsPopupButtonVisible

Gets whether the toggle popup button is visible.

public bool IsPopupButtonVisible { get; }

Property Value

Boolean:

true if the toggle popup button is visible; otherwise false. The default value is false.

Remarks

The HasPopupButton property determines whether the toggle popup button is visible.

IsPopupOpen

Gets or sets whether the popup is open.

public bool IsPopupOpen { get; set; }

Property Value

Boolean:

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

IsPopupOpenedOnFocus

Gets or sets whether the popup automatically opens when the control gains focus.

public bool IsPopupOpenedOnFocus { get; set; }

Property Value

Boolean:

true if the popup automatically opens when the control gains focus; otherwise, false. The default value is false.

IsReadOnly

Gets or sets a value indicating whether the control is read-only.

public bool IsReadOnly { get; set; }

Property Value

Boolean:

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

ItemContainerStyle

Gets or sets the Style that is applied to the container generated for each item.

public Style ItemContainerStyle { get; set; }

Property Value

Style:

The Style that is applied to the container generated for each item. The default value is null.

ItemContainerStyleSelector

Gets or sets custom style-selection logic for a style that can be applied to each generated container.

public StyleSelector ItemContainerStyleSelector { get; set; }

Property Value

StyleSelector:

A StyleSelector object that contains logic that chooses the style to use as the ItemContainerStyle. The default value is null.

ItemsSource

Gets or sets the collection of suggestion items that is filtered based on the user-entered text.

public IEnumerable ItemsSource { get; set; }

Property Value

IEnumerable:

The collection of suggested items that is filtered based on the user-entered text.

ItemTemplate

Gets or sets the DataTemplate used to render items in the suggestion list.

public DataTemplate ItemTemplate { get; set; }

Property Value

DataTemplate:

The DataTemplate used to render items in the suggestion list.

ItemTemplateSelector

Gets or sets the DataTemplateSelector used to render items in the suggestion list.

public DataTemplateSelector ItemTemplateSelector { get; set; }

Property Value

DataTemplateSelector:

The DataTemplateSelector used to render items in the suggestion list.

MaxPopupHeight

Gets or sets the maximum height of the popup.

public double MaxPopupHeight { get; set; }

Property Value

Double:

The maximum height of the popup. The default value is 500.

MinCharacterCountToOpenPopup

Gets or sets the minimum number of characters that need to be typed to open the popup.

public int MinCharacterCountToOpenPopup { get; set; }

Property Value

Int32:

The minimum number of characters that need to be typed to open the popup. The default value is 1.

NoItemsContent

Gets or sets the content to display when the popup is open but there are no suggested items.

public object NoItemsContent { get; set; }

Property Value

Object:

The content to display when the popup is open but there are no suggested items.

NoItemsContentTemplate

Gets or sets the DataTemplate to display when the popup is open but there are no suggested items.

public DataTemplate NoItemsContentTemplate { get; set; }

Property Value

DataTemplate:

The DataTemplate to display when the popup is open but there are no suggested items.

PlaceholderText

Gets or sets the placeholder text to be displayed in the control.

public string PlaceholderText { get; set; }

Property Value

String:

The placeholder text to be displayed in the control.

SelectedItem

Gets or sets the selected suggested item.

public object SelectedItem { get; set; }

Property Value

Object:

The selected suggested item.

Text

Gets or sets the text being edited in the control.

public string Text { get; set; }

Property Value

String:

The text being edited in the control.

TextAlignment

Gets or sets the text alignment of the text editing area.

public TextAlignment TextAlignment { get; set; }

Property Value

TextAlignment:

The text alignment of the text editing area. The default value is TextAlignment.Left.

TextMemberPath

Gets or sets the name of the property that provides each item's text.

public string TextMemberPath { get; set; }

Property Value

String:

The name of the property that provides each item's text.

Methods

ConvertToString(Object)

Converts the specified suggested item to a string representation.

protected virtual string ConvertToString(object itemToConvert)
Parameter Type Description
itemToConvert Object

The suggested item to convert.

Returns

String:

The string representation of the specified suggested item.

OnApplyTemplate()

Invoked whenever application code or internal processes call ApplyTemplate.

public override void OnApplyTemplate()

OnCreateAutomationPeer()

Returns an AutomationPeer object for this control instance.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

An AutomationPeer instance.

OnGotFocus(RoutedEventArgs)

Occurs when the control gains focus.

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

The RoutedEventArgs that contains the event data.

OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs)

Reports that the IsKeyboardFocusWithin property changed.

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

A DependencyPropertyChangedEventArgs that contains the event data.

OnLostMouseCapture(MouseEventArgs)

Occurs when mouse capture is lost.

protected override void OnLostMouseCapture(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

The MouseEventArgs that contains the event data.

OnMouseWheel(MouseWheelEventArgs)

Occurs when the mouse wheel is rotated.

protected override void OnMouseWheel(MouseWheelEventArgs e)
Parameter Type Description
e MouseWheelEventArgs

The MouseWheelEventArgs that contains the event data.

OnPreviewMouseDown(MouseButtonEventArgs)

Occurs before a mouse button is pressed over the control.

protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
Parameter Type Description
e MouseButtonEventArgs

The MouseButtonEventArgs that contains the event data.

OnSelectedItemChanged(AutoCompleteBoxEventArgs)

Occurs when the SelectedItem property has changed.

protected virtual void OnSelectedItemChanged(AutoCompleteBoxEventArgs e)
Parameter Type Description
e AutoCompleteBoxEventArgs

The AutoCompleteBoxEventArgs that contains 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.

OnSubmitted(AutoCompleteBoxEventArgs)

Occurs when the end user submits a text entry, generally by pressing Enter.

protected virtual void OnSubmitted(AutoCompleteBoxEventArgs e)
Parameter Type Description
e AutoCompleteBoxEventArgs

The AutoCompleteBoxEventArgs that contains 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.

OnSuggestionChosen(AutoCompleteBoxEventArgs)

Occurs when a suggested item is chosen and needs to be converted to text.

protected virtual void OnSuggestionChosen(AutoCompleteBoxEventArgs e)
Parameter Type Description
e AutoCompleteBoxEventArgs

The AutoCompleteBoxEventArgs that contains 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.

OnTextChanged(AutoCompleteBoxEventArgs)

Occurs when the Text is changed.

protected virtual void OnTextChanged(AutoCompleteBoxEventArgs e)
Parameter Type Description
e AutoCompleteBoxEventArgs

The AutoCompleteBoxEventArgs that contains 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.

SelectAll()

Selects all the contents of the text-editing control.

public void SelectAll()

Events

SelectedItemChanged

Occurs when the SelectedItem property has changed.

public event EventHandler<AutoCompleteBoxEventArgs> SelectedItemChanged

Event Type

EventHandler<AutoCompleteBoxEventArgs>

Submitted

Occurs when the end user submits a text entry, generally by pressing Enter.

public event EventHandler<AutoCompleteBoxEventArgs> Submitted

Event Type

EventHandler<AutoCompleteBoxEventArgs>

SuggestionChosen

Occurs when a suggested item is chosen and needs to be converted to text.

public event EventHandler<AutoCompleteBoxEventArgs> SuggestionChosen

Event Type

EventHandler<AutoCompleteBoxEventArgs>

TextChanged

Occurs when the Text is changed.

public event EventHandler<AutoCompleteBoxEventArgs> TextChanged

Event Type

EventHandler<AutoCompleteBoxEventArgs>

Fields

CanSelectAllOnUpdateProperty

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

public static readonly DependencyProperty CanSelectAllOnUpdateProperty

CharacterCasingProperty

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

public static readonly DependencyProperty CharacterCasingProperty

DataFilterProperty

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

public static readonly DependencyProperty DataFilterProperty

DisplayMemberPathProperty

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

public static readonly DependencyProperty DisplayMemberPathProperty

HasClearButtonProperty

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

public static readonly DependencyProperty HasClearButtonProperty

HasItemsProperty

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

public static readonly DependencyProperty HasItemsProperty

HasPopupButtonProperty

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

public static readonly DependencyProperty HasPopupButtonProperty

InputModeProperty

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

public static readonly DependencyProperty InputModeProperty

IsClearButtonVisibleProperty

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

public static readonly DependencyProperty IsClearButtonVisibleProperty

IsPopupButtonVisibleProperty

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

public static readonly DependencyProperty IsPopupButtonVisibleProperty

IsPopupOpenedOnFocusProperty

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

public static readonly DependencyProperty IsPopupOpenedOnFocusProperty

IsPopupOpenProperty

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

public static readonly DependencyProperty IsPopupOpenProperty

IsReadOnlyProperty

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

public static readonly DependencyProperty IsReadOnlyProperty

ItemContainerStyleProperty

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

public static readonly DependencyProperty ItemContainerStyleProperty

ItemContainerStyleSelectorProperty

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

public static readonly DependencyProperty ItemContainerStyleSelectorProperty

ItemsSourceProperty

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

public static readonly DependencyProperty ItemsSourceProperty

ItemTemplateProperty

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

public static readonly DependencyProperty ItemTemplateProperty

ItemTemplateSelectorProperty

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

public static readonly DependencyProperty ItemTemplateSelectorProperty

MaxPopupHeightProperty

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

public static readonly DependencyProperty MaxPopupHeightProperty

MinCharacterCountToOpenPopupProperty

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

public static readonly DependencyProperty MinCharacterCountToOpenPopupProperty

NoItemsContentProperty

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

public static readonly DependencyProperty NoItemsContentProperty

NoItemsContentTemplateProperty

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

public static readonly DependencyProperty NoItemsContentTemplateProperty

PlaceholderTextProperty

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

public static readonly DependencyProperty PlaceholderTextProperty

SelectedItemChangedEvent

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

public static readonly RoutedEvent SelectedItemChangedEvent

SelectedItemProperty

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

public static readonly DependencyProperty SelectedItemProperty

SubmittedEvent

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

public static readonly RoutedEvent SubmittedEvent

SuggestionChosenEvent

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

public static readonly RoutedEvent SuggestionChosenEvent

TextAlignmentProperty

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

public static readonly DependencyProperty TextAlignmentProperty

TextChangedEvent

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

public static readonly RoutedEvent TextChangedEvent

TextMemberPathProperty

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

public static readonly DependencyProperty TextMemberPathProperty

TextProperty

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

public static readonly DependencyProperty TextProperty

Inherited Members

Extension Methods