Class AutoSuggestBox
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
ElementSuggestionsPopup
protected const string ElementSuggestionsPopup = "PART_SuggestionsPopup"
Field Value
ElementTextBox
protected const string ElementTextBox = "PART_TextBox"
Field Value
FocusCommandProperty
Identifies the FocusCommand dependency property.
public static readonly DependencyProperty FocusCommandProperty
Field Value
IconProperty
Identifies the Icon dependency property.
public static readonly DependencyProperty IconProperty
Field Value
IsSuggestionListOpenProperty
Identifies the IsSuggestionListOpen dependency property.
public static readonly DependencyProperty IsSuggestionListOpenProperty
Field Value
MaxSuggestionListHeightProperty
Identifies the MaxSuggestionListHeight dependency property.
public static readonly DependencyProperty MaxSuggestionListHeightProperty
Field Value
OriginalItemsSourceProperty
Identifies the OriginalItemsSource dependency property.
public static readonly DependencyProperty OriginalItemsSourceProperty
Field Value
PlaceholderTextProperty
Identifies the PlaceholderText dependency property.
public static readonly DependencyProperty PlaceholderTextProperty
Field Value
QuerySubmittedEvent
Identifies the QuerySubmitted routed event.
public static readonly RoutedEvent QuerySubmittedEvent
Field Value
SuggestionChosenEvent
Identifies the SuggestionChosen routed event.
public static readonly RoutedEvent SuggestionChosenEvent
Field Value
TextChangedEvent
Identifies the TextChanged routed event.
public static readonly RoutedEvent TextChangedEvent
Field Value
TextProperty
Identifies the Text dependency property.
public static readonly DependencyProperty TextProperty
Field Value
UpdateTextOnSelectProperty
Identifies the UpdateTextOnSelect dependency property.
public static readonly DependencyProperty UpdateTextOnSelectProperty
Field Value
Properties
FocusCommand
Gets command used for focusing control.
public ICommand FocusCommand { get; }
Property Value
Icon
Gets or sets displayed IconElement.
public IconElement? Icon { get; set; }
Property Value
IsSuggestionListOpen
Gets or sets a value indicating whether the drop-down portion of the AutoSuggestBox is open.
public bool IsSuggestionListOpen { get; set; }
Property Value
MaxSuggestionListHeight
Gets or sets the maximum height for the drop-down portion of the AutoSuggestBox control.
public double MaxSuggestionListHeight { get; set; }
Property Value
OriginalItemsSource
Gets or sets your items here if you want to use the default filtering
public IList OriginalItemsSource { get; set; }
Property Value
PlaceholderText
Gets or sets the placeholder text to be displayed in the control.
public string PlaceholderText { get; set; }
Property Value
Remarks
The placeholder text to be displayed in the control. The default is an empty string.
SuggestionsList
protected ListView? SuggestionsList { get; set; }
Property Value
SuggestionsPopup
protected Popup SuggestionsPopup { get; set; }
Property Value
Text
Gets or sets the text that is shown in the control.
public string Text { get; set; }
Property Value
Remarks
This property is not typically set in XAML.
TextBox
protected TextBox? TextBox { get; set; }
Property Value
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
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
stringCurrently submitted query text.
OnSuggestionChosen(object)
Method for SuggestionChosen.
protected virtual void OnSuggestionChosen(object selectedItem)
Parameters
selectedItem
objectCurrently selected item.
OnTextChanged(AutoSuggestionBoxTextChangeReason, string)
Method for TextChanged.
protected virtual void OnTextChanged(AutoSuggestionBoxTextChangeReason reason, string text)
Parameters
reason
AutoSuggestionBoxTextChangeReasonData for the text changed event.
text
stringChanged text.
ReleaseTemplateResources()
protected virtual void ReleaseTemplateResources()
Events
QuerySubmitted
Occurs when the user submits a search query.
public event TypedEventHandler<AutoSuggestBox, AutoSuggestBoxQuerySubmittedEventArgs> QuerySubmitted
Event Type
SuggestionChosen
Event occurs when the user selects an item from the recommended ones.
public event TypedEventHandler<AutoSuggestBox, AutoSuggestBoxSuggestionChosenEventArgs> SuggestionChosen
Event Type
TextChanged
Raised after the text content of the editable control component is updated.
public event TypedEventHandler<AutoSuggestBox, AutoSuggestBoxTextChangedEventArgs> TextChanged