Compartir a través de


AutoCompleteBox.ItemsSource Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets a collection that is used to generate the items for the drop-down portion of the AutoCompleteBox control.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Input (in System.Windows.Controls.Input.dll)

Syntax

'Declaration
Public Property ItemsSource As IEnumerable
public IEnumerable ItemsSource { get; set; }
<sdk:AutoCompleteBox ItemsSource="bindingDeclaration"/>
-or-
<sdk:AutoCompleteBox ItemsSource="resourceReferenceToIEnumerable"/>

XAML Values

  • bindingDeclaration
    A Binding declaration using a {Binding ...} markup extension. For more information, see Binding Markup Extension or Binding.

  • resourceReferenceToIEnumerable
    A resource reference to an existing object of type IEnumerable from a resources collection. The resource reference must specify the desired IEnumerable by key.

Property Value

Type: System.Collections.IEnumerable
The collection that is used to generate the items of the drop-down portion of the AutoCompleteBox control.

Examples

The following example shows an AutoCompleteBox that provides a list of cities to complete an entry in its text box. This code example requires a reference to the System.Windows.Controls.Input assembly.

Run this sample

public Page()
{
    InitializeComponent();
    List<string> cities = new List<string>();
    cities.Add("London");
    cities.Add("Seattle");
    cities.Add("Tokyo");
    cities.Add("Nairobi");
    cities.Add("Lisbon");
    cities.Add("New York");
    cities.Add("Paris");
    cities.Add("San Francisco");
    citiesACB.ItemsSource = cities;
}
<Border BorderThickness="3" BorderBrush="Black">
    <StackPanel Background="LightGray">
        <TextBlock Text="AutoCompleteBox Control" Margin="5"/>
        <StackPanel x:Name="LayoutRoot"  Orientation="Horizontal">
            <TextBlock Text="Destination: " Margin="5" VerticalAlignment="Center" />
            <sdk:AutoCompleteBox x:Name="citiesACB" Width="200" />
        </StackPanel>
    </StackPanel>
</Border>

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.