AutoCompleteBox.ItemContainerStyle Property


Gets or sets the Style that is applied to the selection adapter contained in the drop-down portion of the AutoCompleteBox control.

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

Public Property ItemContainerStyle As Style
<sdk:AutoCompleteBox ItemContainerStyle="staticResourceReference"/>

XAML Values


A reference to an existing Style resource in a resource dictionary.

Property Value

Type: System.Windows.Style
The Style applied to the selection adapter contained in the drop-down portion of the AutoCompleteBox control. The default is Nothing.

The default selection adapter contained in the drop-down is a ListBox control, which means the ItemContainerStyle should target the ListBoxItem type.

The following example shows how to set a custom style for the TextBoxStyle and the ItemContainerStyle properties. This code example requires a reference to the System.Windows.Controls.Input assembly.

Run this sample

myACB.ItemsSource = New String() {"London", "Paris", _
    "Johannesburg", "Bucharest", "Berlin", "Lisbon", "New York", _
    "Nairobi", "Seattle", "Mexico City", "Vancouver"}

<Border BorderBrush="DarkGray" BorderThickness="2">
    <StackPanel x:Name="LayoutRoot" Background="LightYellow" Orientation="Vertical">
        <TextBlock Margin="5" Text="TextBoxStyle and ItemContainerStyle Example" />
        <StackPanel Orientation="Horizontal">
                    <Style  x:Key="myTBStyle" TargetType="TextBox">
                    <Setter Property="Background" Value="LightYellow" />
                    <Setter Property="Foreground" Value="DarkSlateGray" />
                    <Setter Property="Margin" Value="5" />
                    <Setter Property="FontWeight" Value="Bold" />
                    <Setter Property="FontSize" Value="14" />
                    <Setter Property="BorderBrush" Value="DarkGray" />
                <Style  x:Key="myLBStyle" TargetType="ListBoxItem">
                    <Setter Property="Background" Value="Khaki" />
                    <Setter Property="Foreground" Value="DarkSlateGray" />
                    <Setter Property="Margin" Value="5" />
                    <Setter Property="FontStyle" Value="Italic" />
                    <Setter Property="FontSize" Value="14" />
                    <Setter Property="BorderBrush" Value="DarkGray" />
            <TextBox Height="30" Width="Auto" IsReadOnly="True" Text="Enter city:" 
                Style="{StaticResource myTBStyle}" BorderBrush="LightGray" />
            <sdk:AutoCompleteBox Width="150"  Height="30" x:Name="myACB" 
                TextBoxStyle="{StaticResource myTBStyle}" 
                ItemContainerStyle="{StaticResource myLBStyle}" />


Supported in: 5, 4, 3

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

Community Additions