Information
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.

GroupStyle class

Applies to Windows and Windows Phone

Describes how to display the grouped items in a collection, such as the collection from GroupItems.

Inheritance

Object
  GroupStyle

Syntax


public class GroupStyle : INotifyPropertyChanged

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The GroupStyle class has these types of members:

Constructors

The GroupStyle class has these constructors.

ConstructorDescription
GroupStyle Initializes a new instance of the GroupStyle class.

 

Events

The GroupStyle class has these events.

EventDescription
PropertyChanged Occurs when a property value changes.

 

Methods

The GroupStyle class inherits methods from the Object class.

Properties

The GroupStyle class has these properties.

PropertyAccess typeDescription

ContainerStyle

Read/writeGets or sets the style that is applied to the GroupItem generated for each item.

ContainerStyleSelector

Read/writeGets or sets a reference to a custom StyleSelector logic class. The StyleSelector referenced by this property returns a style to apply to each generated GroupItem.

HeaderContainerStyle

Read/writeGets or sets the style that is applied to the header for each item.

HeaderTemplate

Read/writeGets or sets the template that is used to display the group header.

HeaderTemplateSelector

Read/writeGets or sets a reference to a custom DataTemplateSelector logic class. The DataTemplateSelector returns different DataTemplate values to use for the header area of group item content.

HidesIfEmpty

Read/writeGets or sets a value that indicates whether items corresponding to empty groups should be displayed.

Panel

Read/writeGets or sets a template that creates the panel used to lay out the items.

 

Remarks

A GroupStyle is typically defined in Extensible Application Markup Language (XAML) and then set as the value of the ItemsControl.GroupStyle property to define the visual look of the groups.

Examples

Here, a GroupStyle is applied to a GridView control that contains grouped data. For more info, and to see the full example code, see How to group items in a list or grid.


<GridView ItemsSource="{Binding Source={StaticResource cvsProjects}}" 
  Margin="0,120,0,0" MaxHeight="500" Grid.Column="1">
    <GridView.ItemTemplate>
        <DataTemplate>
            <StackPanel Margin="20">
                <TextBlock Text="{Binding Name}" FontWeight="Bold" 
                           Style="{StaticResource BaseTextBlockStyle}"/>
                <TextBlock Text="{Binding DueDate}" TextWrapping="NoWrap" 
                           Style="{StaticResource BodyTextBlockStyle}" />
                <CheckBox Content="Complete" IsChecked="{Binding Complete}" 
                          IsEnabled="False"/>
            </StackPanel>
        </DataTemplate>
    </GridView.ItemTemplate>
    <GridView.ItemsPanel>
        <ItemsPanelTemplate>
            <ItemsWrapGrid MaximumRowsOrColumns="3"/>
        </ItemsPanelTemplate>
    </GridView.ItemsPanel>

    <GridView.GroupStyle>
        <GroupStyle HidesIfEmpty="True">
            <GroupStyle.HeaderTemplate>
                <DataTemplate>
                    <Grid Background="LightGray" Margin="0">
                        <TextBlock Text='{Binding Name}' 
                                   Foreground="Black" Margin="30"
                                   Style="{StaticResource HeaderTextBlockStyle}"/>
                    </Grid>
                </DataTemplate>
            </GroupStyle.HeaderTemplate>

        </GroupStyle>
    </GridView.GroupStyle>
</GridView>


Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

ItemsControl.GroupStyle
GroupItem
INotifyPropertyChanged
How to group items in a list or grid

 

 

Show:
© 2014 Microsoft