Export (0) Print
Expand All
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ListBox.ItemContainerStyle Property

May 11, 2014

Gets or sets the style that is used when rendering the item containers.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public Style ItemContainerStyle { get; set; }
<object ItemContainerStyle="resourceReferenceToStyle"/>

XAML Values


A single Style object element. That Style would typically have multiple setters that set properties on the item container type being targeted. (For ListBox, that type is ListBoxItem.)


A resource reference to an existing Style from a resources collection.

Property Value

Type: System.Windows.Style
The style applied to the item containers. The default is null.

Dependency property identifier field: ItemContainerStyleProperty

The following code example shows how to set the ItemContainerStyle property.

    <Grid x:Name="LayoutRoot" Background="Transparent">
            <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" />
            <ListBox Height="184"  ItemContainerStyle="{StaticResource myLBStyle}"  HorizontalAlignment="Left" 
                 Margin="23,24,0,0" Name="listBox1" VerticalAlignment="Top" Width="204" >
                <ListBoxItem Content="Item1" />
                <ListBoxItem Content="Item2" />
                <ListBoxItem Content="Item3" />

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2014 Microsoft