GroupStyle GroupStyle GroupStyle GroupStyle Class

Definition

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

public : class GroupStyle : IGroupStyle, IGroupStyle2, INotifyPropertyChanged
struct winrt::Windows::UI::Xaml::Controls::GroupStyle : IGroupStyle, IGroupStyle2, INotifyPropertyChanged
public class GroupStyle : IGroupStyle, IGroupStyle2, INotifyPropertyChanged
Public Class GroupStyle Implements IGroupStyle, IGroupStyle2, INotifyPropertyChanged
<GroupStyle />
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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>

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.

Constructors

GroupStyle() GroupStyle() GroupStyle() GroupStyle()

Initializes a new instance of the GroupStyle class.

Properties

ContainerStyle ContainerStyle ContainerStyle ContainerStyle

Note

ContainerStyle may be altered or unavailable for releases after Windows 8.1 and is not supported for ItemsControl.GroupStyle.

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

ContainerStyleSelector ContainerStyleSelector ContainerStyleSelector ContainerStyleSelector

Note

ContainerStyleSelector may be altered or unavailable for releases after Windows 8.1 and is not supported for ItemsControl.GroupStyle.

Gets 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 HeaderContainerStyle HeaderContainerStyle HeaderContainerStyle

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

HeaderTemplate HeaderTemplate HeaderTemplate HeaderTemplate

Gets or sets the template that is used to display the group header.

HeaderTemplateSelector HeaderTemplateSelector HeaderTemplateSelector HeaderTemplateSelector

Gets 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 HidesIfEmpty HidesIfEmpty HidesIfEmpty

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

Panel Panel Panel Panel

Gets or sets a template that creates the panel used to lay out the items.

Events

PropertyChanged PropertyChanged PropertyChanged PropertyChanged

Occurs when a property value changes.

PropertyChanged PropertyChanged PropertyChanged PropertyChanged

Occurs when a property value changes.

See Also