dotnet / dotnet/maui

Add a method to CollectionView to scroll to the top of a group header

Open
#30,668 1 comment 1 reaction 0 assignees View on GitHub
area-controls-collectionview proposal/open
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
296

Description

### Description

Support scrolling to the top of a group header in a `CollectionView` when `IsGrouped = true`. Scrolling to the the top of a group header is not currently supported, only scrolling to the first item in a group.

One solution for this (as shown below) is to add overloads of `GroupableItemsView.ScrollTo`, which would scroll to the top of the provided `group` (or `groupIndex`), including the header. These would not require `ScrollPosition` nor `item` (or `index`), since we would only be concerned with scrolling to groups.

### Public API Changes

```csharp
public partial class GroupableItemsView
{
public void ScrollTo(int groupIndex, bool animate = true);

public void ScrollTo(object group, bool animate = true);
}
```

### Intended Use-Case

This is a common behavior if using groups in a list-like view and some control that will scroll to a selected group (for example, a date picker that will scroll to the start of the group of the selected date).

The closest current functionality is using `ScrollTo` with `ScrollToPosition.Start`, but this cuts off the group heading, making for a worse user experience.

Contributor guide

Open the contributing guide

Research direction

Start by tracing CollectionView and GroupableItemsView scroll APIs, especially the existing ScrollTo overload that uses ScrollToPosition.Start. Check how grouped items and group headers are represented across the supported platforms, then run the relevant CollectionView tests or samples. Done means the proposed groupIndex and group overloads scroll to the top of the requested group header when IsGrouped is true.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, frontend, mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.