docs-maui
docs-maui copied to clipboard
CollectionView does not display grouped data header by default
Type of issue
Code doesn't work
Description
When passing in a collection of group items with name attributes as the CollectionView ItemsSource, the names are not displayed as the header by default like it says in the documentation. A GroupHeaderTemplate must be made and the Name attribute must be passed into it for the header to be displayed.
With GroupHeaderTemplate
Without GroupHeaderTemplate
Page URL
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/collectionview/grouping?view=net-maui-8.0
Content source URL
https://github.com/dotnet/docs-maui/blob/main/docs/user-interface/controls/collectionview/grouping.md
Document Version Independent Id
56201296-c616-f9e0-bf20-e44931abe815
Article author
@davidbritch
Metadata
- ID: 56201296-c616-f9e0-bf20-e44931abe815
- Service: dotnet-mobile
- Sub-service: dotnet-maui
Hi @sethrhod
I'd say that the note is accurate.
Given a CollectionView
that doesn't define a GroupHeaderTemplate
:
<StackLayout Margin="20">
<CollectionView ItemsSource="{Binding Animals}"
IsGrouped="true" />
</StackLayout>
The group header displays the name (iOS screenshot shown, but the same behavior occurs on Android):