Class AutoCompleteBox
Represents a control that provides a text box for user input and a drop-down that contains possible matches based on the input in the text box.
Inherited Members
Namespace: System.Windows.Controls
Assembly: Controls.Input.OpenSilver.dll
Syntax
public class AutoCompleteBox : Control
Constructors
| Improve this Doc View SourceAutoCompleteBox()
Initializes a new instance of the AutoCompleteBox class.
Declaration
public AutoCompleteBox()
Fields
| Improve this Doc View SourceFilterModeProperty
Gets the identifier for the FilterMode dependency property.
Declaration
public static readonly DependencyProperty FilterModeProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
IsDropDownOpenProperty
Identifies the IsDropDownOpen dependency property.
Declaration
public static readonly DependencyProperty IsDropDownOpenProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the IsDropDownOpen dependency property. |
IsTextCompletionEnabledProperty
Identifies the IsTextCompletionEnabled dependency property.
Declaration
public static readonly DependencyProperty IsTextCompletionEnabledProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the IsTextCompletionEnabled dependency property. |
ItemContainerStyleProperty
Identifies the ItemContainerStyle dependency property.
Declaration
public static readonly DependencyProperty ItemContainerStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the ItemContainerStyle dependency property. |
ItemFilterProperty
Identifies the ItemFilter dependency property.
Declaration
public static readonly DependencyProperty ItemFilterProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the ItemFilter dependency property. |
ItemsSourceProperty
Identifies the ItemsSource dependency property.
Declaration
public static readonly DependencyProperty ItemsSourceProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the ItemsSource dependency property. |
ItemTemplateProperty
Identifies the ItemTemplate dependency property.
Declaration
public static readonly DependencyProperty ItemTemplateProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the ItemTemplate dependency property. |
MaxDropDownHeightProperty
Identifies the MaxDropDownHeight dependency property.
Declaration
public static readonly DependencyProperty MaxDropDownHeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the MaxDropDownHeight dependency property. |
MinimumPopulateDelayProperty
Identifies the MinimumPopulateDelay dependency property.
Declaration
public static readonly DependencyProperty MinimumPopulateDelayProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the MinimumPopulateDelay dependency property. |
MinimumPrefixLengthProperty
Identifies the MinimumPrefixLength dependency property.
Declaration
public static readonly DependencyProperty MinimumPrefixLengthProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the MinimumPrefixLength dependency property. |
SearchTextProperty
Identifies the SearchText dependency property.
Declaration
public static readonly DependencyProperty SearchTextProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SearchText dependency property. |
SelectedItemProperty
Identifies the SelectedItem dependency property.
Declaration
public static readonly DependencyProperty SelectedItemProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier the SelectedItem dependency property. |
TextBoxStyleProperty
Identifies the TextBoxStyle dependency property.
Declaration
public static readonly DependencyProperty TextBoxStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the TextBoxStyle dependency property. |
TextFilterProperty
Identifies the TextFilter dependency property.
Declaration
public static readonly DependencyProperty TextFilterProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the TextFilter dependency property. |
TextProperty
Identifies the Text dependency property.
Declaration
public static readonly DependencyProperty TextProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the Text dependency property. |
Properties
| Improve this Doc View SourceFilterMode
Gets or sets how the text in the text box is used to filter items specified by the ItemsSource property for display in the drop-down.
Declaration
public AutoCompleteFilterMode FilterMode { get; set; }
Property Value
Type | Description |
---|---|
AutoCompleteFilterMode | One of the AutoCompleteFilterMode values The default is StartsWith. |
Remarks
Use the FilterMode property to specify how possible matches are filtered. For example, possible matches can be filtered in a predefined or custom way. The search mode is automatically set to Custom if you set the ItemFilter property.
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The specified value is not a valid AutoCompleteFilterMode. |
IsDropDownOpen
Gets or sets a value indicating whether the drop-down portion of the control is open.
Declaration
public bool IsDropDownOpen { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the drop-down is open; otherwise, false. The default is false. |
IsTextCompletionEnabled
Gets or sets a value indicating whether the first possible match found during the filtering process will be displayed automatically in the text box.
Declaration
public bool IsTextCompletionEnabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the first possible match found will be displayed automatically in the text box; otherwise, false. The default is false. |
ItemContainerStyle
Gets or sets the Style that is applied to the selection adapter contained in the drop-down portion of the AutoCompleteBox control.
Declaration
public Style ItemContainerStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The Style applied to the selection adapter contained in the drop-down portion of the AutoCompleteBox control. The default is null. |
Remarks
The default selection adapter contained in the drop-down is a ListBox control.
ItemFilter
Gets or sets the custom method that uses user-entered text to filter the items specified by the ItemsSource property for display in the drop-down.
Declaration
public AutoCompleteFilterPredicate<object> ItemFilter { get; set; }
Property Value
Type | Description |
---|---|
AutoCompleteFilterPredicate<System.Object> | The custom method that uses the user-entered text to filter the items specified by the ItemsSource property. The default is null. |
Remarks
The filter mode is automatically set to Custom if you set the ItemFilter property.
ItemsSource
Gets or sets a collection that is used to generate the items for the drop-down portion of the AutoCompleteBox control.
Declaration
public IEnumerable ItemsSource { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.IEnumerable | The collection that is used to generate the items of the drop-down portion of the AutoCompleteBox control. |
ItemTemplate
Gets or sets the DataTemplate used to display each item in the drop-down portion of the control.
Declaration
public DataTemplate ItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
DataTemplate | The DataTemplate used to display each item in the drop-down. The default is null. |
Remarks
You use the ItemTemplate property to specify the visualization of the data objects in the drop-down portion of the AutoCompleteBox control. If your AutoCompleteBox is bound to a collection and you do not provide specific display instructions by using a DataTemplate, the resulting UI of each item is a string representation of each object in the underlying collection.
MaxDropDownHeight
Gets or sets the maximum height of the drop-down portion of the AutoCompleteBox control.
Declaration
public double MaxDropDownHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The maximum height of the drop-down portion of the AutoCompleteBox control. The default is System.Double.PositiveInfinity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The specified value is less than 0. |
MinimumPopulateDelay
Gets or sets the minimum delay, in milliseconds, after text is typed in the text box before the AutoCompleteBox control populates the list of possible matches in the drop-down.
Declaration
public int MinimumPopulateDelay { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The minimum delay, in milliseconds, after text is typed in the text box, but before the AutoCompleteBox populates the list of possible matches in the drop-down. The default is 0. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The set value is less than 0. |
MinimumPrefixLength
Gets or sets the minimum number of characters required to be entered in the text box before the AutoCompleteBox displays possible matches. matches.
Declaration
public int MinimumPrefixLength { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The minimum number of characters to be entered in the text box before the AutoCompleteBox displays possible matches. The default is 1. |
Remarks
If you set MinimumPrefixLength to -1, the AutoCompleteBox will not provide possible matches. There is no maximum value, but setting MinimumPrefixLength to value that is too large will prevent the AutoCompleteBox from providing possible matches as well.
SearchText
Gets the text that is used to filter items in the ItemsSource item collection.
Declaration
public string SearchText { get; }
Property Value
Type | Description |
---|---|
System.String | The text that is used to filter items in the ItemsSource item collection. |
Remarks
The SearchText value is typically the same as the Text property, but is set after the TextChanged event occurs and before the Populating event.
SelectedItem
Gets or sets the selected item in the drop-down.
Declaration
public object SelectedItem { get; set; }
Property Value
Type | Description |
---|---|
System.Object | The selected item in the drop-down. |
Remarks
If the IsTextCompletionEnabled property is true and text typed by the user matches an item in the ItemsSource collection, which is then displayed in the text box, the SelectedItem property will be a null reference.
SelectionAdapter
Gets or sets the selection adapter used to populate the drop-down with a list of selectable items.
Declaration
protected ISelectionAdapter SelectionAdapter { get; set; }
Property Value
Type | Description |
---|---|
ISelectionAdapter | The selection adapter used to populate the drop-down with a list of selectable items. |
Remarks
You can use this property when you create an automation peer to use with AutoCompleteBox or deriving from AutoCompleteBox to create a custom control.
Text
Gets or sets the text in the text box portion of the AutoCompleteBox control.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | The text in the text box portion of the AutoCompleteBox control. |
TextBoxStyle
Gets or sets the Style applied to the text box portion of the AutoCompleteBox control.
Declaration
public Style TextBoxStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The Style applied to the text box portion of the AutoCompleteBox control. The default is null. |
TextFilter
Gets or sets the custom method that uses the user-entered text to filter items specified by the ItemsSource property in a text-based way for display in the drop-down.
Declaration
public AutoCompleteFilterPredicate<string> TextFilter { get; set; }
Property Value
Type | Description |
---|---|
AutoCompleteFilterPredicate<System.String> | The custom method that uses the user-entered text to filter items specified by the ItemsSource property in a text-based way for display in the drop-down. |
Remarks
The search mode is automatically set to Custom if you set the TextFilter property.
ValueMemberBinding
Gets or sets the Binding that is used to get the values for display in the text portion of the AutoCompleteBox control.
Declaration
public Binding ValueMemberBinding { get; set; }
Property Value
Type | Description |
---|---|
Binding | The Binding object used when binding to a collection property. |
ValueMemberPath
Gets or sets the property path that is used to get values for display in the text portion of the AutoCompleteBox control.
Declaration
public string ValueMemberPath { get; set; }
Property Value
Type | Description |
---|---|
System.String | The property path that is used to get values for display in the text portion of the AutoCompleteBox control. |
Methods
| Improve this Doc View SourceArrangeOverride(Size)
Arranges and sizes the AutoCompleteBox control and its contents.
Declaration
protected override Size ArrangeOverride(Size finalSize)
Parameters
Type | Name | Description |
---|---|---|
Size | finalSize | The size allowed for the AutoCompleteBox control. |
Returns
Type | Description |
---|---|
Size | The |
Overrides
| Improve this Doc View SourceFormatValue(Object)
Converts the specified object to a string by using the Converter and ConverterCulture values of the binding object specified by the ValueMemberBinding property.
Declaration
protected virtual string FormatValue(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to format as a string. |
Returns
Type | Description |
---|---|
System.String | The string representation of the specified object. |
Remarks
Override this method to provide a custom string conversion.
GetSelectionAdapterPart()
Returns the ISelectionAdapter part, if possible.
Declaration
protected virtual ISelectionAdapter GetSelectionAdapterPart()
Returns
Type | Description |
---|---|
ISelectionAdapter | A ISelectionAdapter object, if possible. Otherwise, null. |
HasFocus()
Determines whether the text box or drop-down portion of the AutoCompleteBox control has focus.
Declaration
protected bool HasFocus()
Returns
Type | Description |
---|---|
System.Boolean | true to indicate the AutoCompleteBox has focus; otherwise, false. |
OnApplyTemplate()
Builds the visual tree for the AutoCompleteBox control when a new template is applied.
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnCreateAutomationPeer()
Returns a AutoCompleteBoxAutomationPeer for use by the Silverlight automation infrastructure.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
AutomationPeer | A AutoCompleteBoxAutomationPeer for the AutoCompleteBox object. |
Overrides
| Improve this Doc View SourceOnDropDownClosed(RoutedPropertyChangedEventArgs<Boolean>)
Raises the DropDownClosed event.
Declaration
protected virtual void OnDropDownClosed(RoutedPropertyChangedEventArgs<bool> e)
Parameters
Type | Name | Description |
---|---|---|
RoutedPropertyChangedEventArgs<System.Boolean> | e | A RoutedPropertyChangedEventArgs<T> which contains the event data. |
OnDropDownClosing(RoutedPropertyChangingEventArgs<Boolean>)
Raises the DropDownClosing event.
Declaration
protected virtual void OnDropDownClosing(RoutedPropertyChangingEventArgs<bool> e)
Parameters
Type | Name | Description |
---|---|---|
RoutedPropertyChangingEventArgs<System.Boolean> | e | A RoutedPropertyChangingEventArgs<T> that contains the event data. |
OnDropDownOpened(RoutedPropertyChangedEventArgs<Boolean>)
Raises the DropDownOpened event.
Declaration
protected virtual void OnDropDownOpened(RoutedPropertyChangedEventArgs<bool> e)
Parameters
Type | Name | Description |
---|---|---|
RoutedPropertyChangedEventArgs<System.Boolean> | e | A RoutedPropertyChangedEventArgs<T> that contains the event data. |
OnDropDownOpening(RoutedPropertyChangingEventArgs<Boolean>)
Raises the DropDownOpening event.
Declaration
protected virtual void OnDropDownOpening(RoutedPropertyChangingEventArgs<bool> e)
Parameters
Type | Name | Description |
---|---|---|
RoutedPropertyChangingEventArgs<System.Boolean> | e | A RoutedPropertyChangingEventArgs<T> that contains the event data. |
OnGotFocus(RoutedEventArgs)
Provides handling for the GotFocus event.
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains the event data. |
Overrides
| Improve this Doc View SourceOnKeyDown(KeyEventArgs)
Provides handling for the KeyDown event.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | A KeyEventArgs that contains the event data. |
Overrides
| Improve this Doc View SourceOnLostFocus(RoutedEventArgs)
Provides handling for the LostFocus event.
Declaration
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains the event data. |
Overrides
| Improve this Doc View SourceOnPopulated(PopulatedEventArgs)
Raises the Populated event.
Declaration
protected virtual void OnPopulated(PopulatedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PopulatedEventArgs | e | A PopulatedEventArgs that contains the event data. |
OnPopulating(PopulatingEventArgs)
Raises the Populating event.
Declaration
protected virtual void OnPopulating(PopulatingEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PopulatingEventArgs | e | A PopulatingEventArgs that contains the event data. |
OnSelectionChanged(SelectionChangedEventArgs)
Raises the SelectionChanged event.
Declaration
protected virtual void OnSelectionChanged(SelectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
SelectionChangedEventArgs | e | A SelectionChangedEventArgs that contains the event data. |
OnTextChanged(RoutedEventArgs)
Raises the TextChanged event.
Declaration
protected virtual void OnTextChanged(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains the event data. |
PopulateComplete()
Notifies the AutoCompleteBox that the ItemsSource property has been set and the data can be filtered to provide possible matches in the drop-down.
Declaration
public void PopulateComplete()
Remarks
Call this method when you are providing custom population of the drop-down portion of the AutoCompleteBox, to signal the control that you are done with the population process. Typically, you use PopulateComplete when the population process is a long-running process and you want to cancel built-in filtering of the ItemsSource items. In this case, you can handle the Populated event and set PopulatingEventArgs.Cancel to true. When the long-running process has completed you call PopulateComplete to indicate the drop-down is populated.
Events
| Improve this Doc View SourceDropDownClosed
Occurs when the IsDropDownOpen property was changed from true to false and the drop-down is open.
Declaration
public event RoutedPropertyChangedEventHandler<bool> DropDownClosed
Event Type
Type | Description |
---|---|
RoutedPropertyChangedEventHandler<System.Boolean> |
DropDownClosing
Occurs when the IsDropDownOpen property is changing from true to false.
Declaration
public event RoutedPropertyChangingEventHandler<bool> DropDownClosing
Event Type
Type | Description |
---|---|
RoutedPropertyChangingEventHandler<System.Boolean> |
DropDownOpened
Occurs when the value of the IsDropDownOpen property has changed from false to true and the drop-down is open.
Declaration
public event RoutedPropertyChangedEventHandler<bool> DropDownOpened
Event Type
Type | Description |
---|---|
RoutedPropertyChangedEventHandler<System.Boolean> |
DropDownOpening
Occurs when the value of the IsDropDownOpen property is changing from false to true.
Declaration
public event RoutedPropertyChangingEventHandler<bool> DropDownOpening
Event Type
Type | Description |
---|---|
RoutedPropertyChangingEventHandler<System.Boolean> |
Populated
Occurs when the AutoCompleteBox has populated the drop-down with possible matches based on the Text property.
Declaration
public event PopulatedEventHandler Populated
Event Type
Type | Description |
---|---|
PopulatedEventHandler |
Populating
Occurs when the AutoCompleteBox is populating the drop-down with possible matches based on the Text property.
Declaration
public event PopulatingEventHandler Populating
Event Type
Type | Description |
---|---|
PopulatingEventHandler |
Remarks
If the event is canceled, by setting the PopulatingEventArgs.Cancel property to true, the AutoCompleteBox will not automatically populate the selection adapter contained in the drop-down. In this case, if you want possible matches to appear, you must provide the logic for populating the selection adapter.
SelectionChanged
Occurs when the selected item in the drop-down portion of the AutoCompleteBox has changed.
Declaration
public event SelectionChangedEventHandler SelectionChanged
Event Type
Type | Description |
---|---|
SelectionChangedEventHandler |
TextChanged
Occurs when the text in the text box portion of the AutoCompleteBox changes.
Declaration
public event RoutedEventHandler TextChanged
Event Type
Type | Description |
---|---|
RoutedEventHandler |