This documentation is archived and is not being maintained.

GroupStyle.ContainerStyle Property

Gets or sets the style that is applied to the GroupItem generated for each item.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:

public Style ContainerStyle { get; set; }
/** @property */
public Style get_ContainerStyle ()

/** @property */
public void set_ContainerStyle (Style value)

public function get ContainerStyle () : Style

public function set ContainerStyle (value : Style)

    <Style .../>
<object ContainerStyle="{ResourceExtension StyleResourceKey}"/>
 ResourceExtension  One of the following: StaticResource, or DynamicResource. See Resources Overview.  StyleResourceKey  The key that identifies the style being requested. The key refers to an existing resource in a ResourceDictionary. 

Property Value

The style that is applied to the GroupItem generated for each item. The default value is a null reference (Nothing in Visual Basic).

This property is a rare case where creating a Style inline in property element syntax, rather than creating the style as a resource, is a reasonable alternative methodology.

This example shows how to display groups of items in the GridView view mode of a ListView control.

To display groups of items in a ListView, define a CollectionViewSource. The following example shows a CollectionViewSource that groups data items according to the value of the Catalog data field.

<CollectionViewSource x:Key='src' 
                      Source="{Binding Source={StaticResource MyData}, 
    <PropertyGroupDescription PropertyName="@Catalog" />

The following example sets the ItemsSource for the ListView to the CollectionViewSource that the previous example defines. The example also defines a GroupStyle that implements an Expander control.

<ListView ItemsSource='{Binding Source={StaticResource src}}' 
        <Style TargetType="{x:Type GroupItem}">
          <Setter Property="Margin" Value="0,0,0,5"/>
          <Setter Property="Template">
              <ControlTemplate TargetType="{x:Type GroupItem}">
                <Expander IsExpanded="True" BorderBrush="#FFA4B97F" 
                      <TextBlock FontWeight="Bold" Text="{Binding Path=Name}" 
                                 Margin="5,0,0,0" Width="100"/>
                      <TextBlock FontWeight="Bold" 
                                 Text="{Binding Path=ItemCount}"/>
                    <ItemsPresenter />



For the complete sample, see ListView Grouping Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0