microsoft / microsoft/CsWinRT

Bug: Unexpected behavior of CollectionViewSource with grouping

Open
#2,304 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
665
Forks
134
Avg merge
1d 3h
Merged PRs (30d)
32

Description

Description

Hello.

I'm porting a UWP application to .NET 9 and I'm running into issues with CollectionViewSource when working with grouped collections.

I use a custom grouped observable collection. It has its own Grouping<TKey, TItem> type with a Key property and a Values property (which contains the items in that group).

The porting process is stuck because of problems with my custom collection.

I created a minimal reproducible example with two variants:

  1. My custom grouped observable collection (shows groups by DateTime + view model class or DateTime values)
  2. Manually created grouped collection (like in issue #2001, also using DateTime + view model or DateTime value)

When the app runs with both variants present — all groups and items are displayed correctly.

But when I comment out the creation of the manual grouped collection (from issue #2001) — only the group headers are shown in my custom collection; the items inside the groups disappear.

Right column display DateTime(group key and values). Left column display DateTime(header), view model in values.
Image

Commented:

Image

Why my custom collection stop working?
Archive with sources: TestNet9.zip

Steps To Reproduce
  1. Launch the application using the archived build. → Expected: all groups and their items are displayed correctly.
  2. Close the application.
  3. Open MainPage.xaml.cs and comment out lines 36 through 57 (the manual grouped collection creation code).
  4. Rebuild and run again. → Actual: only group headers appear; items within groups are not rendered.
Expected Behavior

Items from my custom collection display without issues. And i don't need another two collections.

Version Info

Microsoft.Windows.CsWinRT 2.3.0-prerelease.251115.2(add as PackageReference)
CommunityToolkit.Mvvm 8.4.0

Microsoft Visual Studio Community 2022
Version 17.14.27 (February 2026)

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached TestNet9.zip and inspect MainPage.xaml.cs, especially lines 36 through 57 that create the manual grouped collection. Reproduce the difference with that code present and commented out, then compare the custom grouped collection's DateTime keys and Values behavior in CollectionViewSource. Done means the custom collection renders both group headers and items without the second collection.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.