Table of Contents

Class AutoSuggestBox

Namespace
Wpf.Ui.Controls
Assembly
Wpf.Ui.dll

Represents a text control that makes suggestions to users as they enter text using a keyboard. The app is notified when text has been changed by the user and is responsible for providing relevant suggestions for this control to display.

[TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))]
[TemplatePart(Name = "PART_SuggestionsPopup", Type = typeof(Popup))]
[TemplatePart(Name = "PART_SuggestionsList", Type = typeof(ListView))]
public class AutoSuggestBox : ItemsControl, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IQueryAmbient, IAddChild, IContainItemStorage, IIconControl
Inheritance
AutoSuggestBox
Implements
Inherited Members

Examples

<ui:AutoSuggestBox x:Name="AutoSuggestBox" PlaceholderText="Search">
    <ui:AutoSuggestBox.Icon>
        <ui:IconSourceElement>
            <ui:SymbolIconSource Symbol="Search24" />
        </ui:IconSourceElement>
    </ui:AutoSuggestBox.Icon>
</ui:AutoSuggestBox>

Constructors

AutoSuggestBox()

public AutoSuggestBox()

Fields

ElementSuggestionsList

protected const string ElementSuggestionsList = "PART_SuggestionsList"

Field Value

string

ElementSuggestionsPopup

protected const string ElementSuggestionsPopup = "PART_SuggestionsPopup"

Field Value

string

ElementTextBox

protected const string ElementTextBox = "PART_TextBox"

Field Value

string

FocusCommandProperty

Identifies the FocusCommand dependency property.

public static readonly DependencyProperty FocusCommandProperty

Field Value

DependencyProperty

IconProperty

Identifies the Icon dependency property.

public static readonly DependencyProperty IconProperty

Field Value

DependencyProperty

IsSuggestionListOpenProperty

Identifies the IsSuggestionListOpen dependency property.

public static readonly DependencyProperty IsSuggestionListOpenProperty

Field Value

DependencyProperty

MaxSuggestionListHeightProperty

Identifies the MaxSuggestionListHeight dependency property.

public static readonly DependencyProperty MaxSuggestionListHeightProperty

Field Value

DependencyProperty

OriginalItemsSourceProperty

Identifies the OriginalItemsSource dependency property.

public static readonly DependencyProperty OriginalItemsSourceProperty

Field Value

DependencyProperty

PlaceholderTextProperty

Identifies the PlaceholderText dependency property.

public static readonly DependencyProperty PlaceholderTextProperty

Field Value

DependencyProperty

QuerySubmittedEvent

Identifies the QuerySubmitted routed event.

public static readonly RoutedEvent QuerySubmittedEvent

Field Value

RoutedEvent

SuggestionChosenEvent

Identifies the SuggestionChosen routed event.

public static readonly RoutedEvent SuggestionChosenEvent

Field Value

RoutedEvent

TextChangedEvent

Identifies the TextChanged routed event.

public static readonly RoutedEvent TextChangedEvent

Field Value

RoutedEvent

TextProperty

Identifies the Text dependency property.

public static readonly DependencyProperty TextProperty

Field Value

DependencyProperty

UpdateTextOnSelectProperty

Identifies the UpdateTextOnSelect dependency property.

public static readonly DependencyProperty UpdateTextOnSelectProperty

Field Value

DependencyProperty

Properties

FocusCommand

Gets command used for focusing control.

public ICommand FocusCommand { get; }

Property Value

ICommand

Icon

Gets or sets displayed IconElement.

public IconElement? Icon { get; set; }

Property Value

IconElement

IsSuggestionListOpen

Gets or sets a value indicating whether the drop-down portion of the AutoSuggestBox is open.

public bool IsSuggestionListOpen { get; set; }

Property Value

bool

MaxSuggestionListHeight

Gets or sets the maximum height for the drop-down portion of the AutoSuggestBox control.

public double MaxSuggestionListHeight { get; set; }

Property Value

double

OriginalItemsSource

Gets or sets your items here if you want to use the default filtering

public IList OriginalItemsSource { get; set; }

Property Value

IList

PlaceholderText

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

public string PlaceholderText { get; set; }

Property Value

string

Remarks

The placeholder text to be displayed in the control. The default is an empty string.

SuggestionsList

protected ListView? SuggestionsList { get; set; }

Property Value

ListView

SuggestionsPopup

protected Popup SuggestionsPopup { get; set; }

Property Value

Popup

Text

Gets or sets the text that is shown in the control.

public string Text { get; set; }

Property Value

string

Remarks

This property is not typically set in XAML.

TextBox

protected TextBox? TextBox { get; set; }

Property Value

TextBox

UpdateTextOnSelect

Gets or sets a value indicating whether items in the view will trigger an update of the editable text part of the AutoSuggestBox when clicked.

public bool UpdateTextOnSelect { get; set; }

Property Value

bool

Methods

AcquireTemplateResources()

protected virtual void AcquireTemplateResources()

Focus()

Attempts to set focus to this element.

public bool Focus()

Returns

bool

true if keyboard focus and logical focus were set to this element; false if only logical focus was set to this element, or if the call to this method did not force the focus to change.

GetTemplateChild<T>(string)

protected T GetTemplateChild<T>(string name) where T : DependencyObject

Parameters

name string

Returns

T

Type Parameters

T

OnApplyTemplate()

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

public override void OnApplyTemplate()

OnQuerySubmitted(string)

Method for QuerySubmitted.

protected virtual void OnQuerySubmitted(string queryText)

Parameters

queryText string

Currently submitted query text.

OnSuggestionChosen(object)

Method for SuggestionChosen.

protected virtual void OnSuggestionChosen(object selectedItem)

Parameters

selectedItem object

Currently selected item.

OnTextChanged(AutoSuggestionBoxTextChangeReason, string)

Method for TextChanged.

protected virtual void OnTextChanged(AutoSuggestionBoxTextChangeReason reason, string text)

Parameters

reason AutoSuggestionBoxTextChangeReason

Data for the text changed event.

text string

Changed text.

ReleaseTemplateResources()

protected virtual void ReleaseTemplateResources()

Events

QuerySubmitted

Occurs when the user submits a search query.

public event TypedEventHandler<AutoSuggestBox, AutoSuggestBoxQuerySubmittedEventArgs> QuerySubmitted

Event Type

TypedEventHandler<AutoSuggestBox, AutoSuggestBoxQuerySubmittedEventArgs>

SuggestionChosen

Event occurs when the user selects an item from the recommended ones.

public event TypedEventHandler<AutoSuggestBox, AutoSuggestBoxSuggestionChosenEventArgs> SuggestionChosen

Event Type

TypedEventHandler<AutoSuggestBox, AutoSuggestBoxSuggestionChosenEventArgs>

TextChanged

Raised after the text content of the editable control component is updated.

public event TypedEventHandler<AutoSuggestBox, AutoSuggestBoxTextChangedEventArgs> TextChanged

Event Type

TypedEventHandler<AutoSuggestBox, AutoSuggestBoxTextChangedEventArgs>