GroupStyle Class

Definition

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

class GroupStyle : INotifyPropertyChanged
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Controls.IGroupStyleFactory), Windows.Foundation.Metadata.CompositionType.Public, 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
public class GroupStyle : INotifyPropertyChanged
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Controls.IGroupStyleFactory), Windows.Foundation.Metadata.CompositionType.Public, 65536, "Windows.Foundation.UniversalApiContract")]
public class GroupStyle : INotifyPropertyChanged
Public Class GroupStyle
Implements INotifyPropertyChanged
<GroupStyle />
Inheritance
GroupStyle
Attributes
Implements
<xref href="System.ComponentModel.INotifyPropertyChanged?alt=System.ComponentModel.INotifyPropertyChanged&text=INotifyPropertyChanged" data-throw-if-not-resolved="True"/>

Windows 10 requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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()

Initializes a new instance of the GroupStyle class.

Properties

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

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

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

HeaderTemplate

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

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

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

Panel

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

Events

PropertyChanged

Occurs when a property value changes.

Applies to

See also