Export (0) Print
Expand All

AutoCompleteBox.ItemContainerStyle Property

Silverlight

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)

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

XAML Values

staticResourceReference

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">
             <StackPanel.Resources>
                    <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>
                <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" />
                </Style>
            </StackPanel.Resources>
            <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}" />
        </StackPanel>
    </StackPanel>
</Border>


Silverlight

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

ADD
Show:
© 2014 Microsoft