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, INotifyPropertyChangedpublic class GroupStyle : IGroupStyle, IGroupStyle2, INotifyPropertyChangedPublic Class GroupStyle Implements IGroupStyle, IGroupStyle2, INotifyPropertyChanged// This API is not available in Javascript.
<GroupStyle />
- Attributes
| 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.
public : GroupStyle()public GroupStyle()Public Sub New()// This API is not available in Javascript.
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.
public : Style ContainerStyle { get; set; }public Style ContainerStyle { get; set; }Public ReadWrite Property ContainerStyle As Style// This API is not available in Javascript.
<GroupStyle ContainerStyle="styleReference" />
The style that is applied to the GroupItem generated for each item. The default is null.
- See Also
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.
public : StyleSelector ContainerStyleSelector { get; set; }public StyleSelector ContainerStyleSelector { get; set; }Public ReadWrite Property ContainerStyleSelector As StyleSelector// This API is not available in Javascript.
<GroupStyle ContainerStyleSelector="styleSelectorReference" />
An object that derives from StyleSelector. The default is null.
HeaderContainerStyle HeaderContainerStyle HeaderContainerStyle HeaderContainerStyle
Gets or sets the style that is applied to the header for each item.
public : Style HeaderContainerStyle { get; set; }public Style HeaderContainerStyle { get; set; }Public ReadWrite Property HeaderContainerStyle As Style// This API is not available in Javascript.
<GroupStyle ...>
<GroupStyle.HeaderContainerStyle>
<Style TargetType="headerItemType">
oneOrMoreSetters
</Style>
</GroupStyle.HeaderContainerStyle>
</GroupStyle>
HeaderTemplate HeaderTemplate HeaderTemplate HeaderTemplate
Gets or sets the template that is used to display the group header.
public : DataTemplate HeaderTemplate { get; set; }public DataTemplate HeaderTemplate { get; set; }Public ReadWrite Property HeaderTemplate As DataTemplate// This API is not available in Javascript.
<GroupStyle HeaderTemplate="dataTemplateReference" />
A DataTemplate object that is used to display the group header. The default is null.
- See Also
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.
public : DataTemplateSelector HeaderTemplateSelector { get; set; }public DataTemplateSelector HeaderTemplateSelector { get; set; }Public ReadWrite Property HeaderTemplateSelector As DataTemplateSelector// This API is not available in Javascript.
<GroupStyle HeaderTemplateSelector="dataTemplateSelectorReference" />
An object that derives from DataTemplateSelector. The default is null.
Remarks
For example XAML that references a custom DataTemplateSelector as the HeaderTemplateSelector value, and example code that shows the overrides for HeaderTemplateSelector methods, see How to group items in a list or grid.
HidesIfEmpty HidesIfEmpty HidesIfEmpty HidesIfEmpty
Gets or sets a value that indicates whether items corresponding to empty groups should be displayed.
public : PlatForm::Boolean HidesIfEmpty { get; set; }public bool HidesIfEmpty { get; set; }Public ReadWrite Property HidesIfEmpty As bool// This API is not available in Javascript.
<GroupStyle HidesIfEmpty="bool" .../>
- Value
- PlatForm::Boolean bool bool bool
True to not display empty groups; otherwise, false. The default is false.
- See Also
Panel Panel Panel Panel
Gets or sets a template that creates the panel used to lay out the items.
public : ItemsPanelTemplate Panel { get; set; }public ItemsPanelTemplate Panel { get; set; }Public ReadWrite Property Panel As ItemsPanelTemplate// This API is not available in Javascript.
<GroupStyle Panel="itemsPanelTemplateReference" />
An ItemsPanelTemplate object that creates the panel used to layout the items.
Remarks
An ItemsPanelTemplate object element should contain exactly one FrameworkElement -derived class that serves as the root element for items. In most cases this is a Panel -derived class. The expanded template serves as the parent for the realized items and there generally is more than one item. Therefore the XAML content property of the intended root element of an ItemsPanelTemplate should support a collection, as Panel.Children does.
Important
The root element of the template declared for the ItemsPanelTemplate in the GroupStyle.Panel property cannot be a virtualizing panel. Virtualizing panels are defined as any type that derives from VirtualizingPanel, for example the VirtualizingStackPanel class.
- See Also
Events
PropertyChanged PropertyChanged PropertyChanged PropertyChanged
Occurs when a property value changes.
This member is not implemented in C++event PropertyChangedEventHandler PropertyChangedEvent PropertyChanged As PropertyChangedEventHandlerevent PropertyChangedEventHandler PropertyChanged