Skip to content

Bug: Unexpected behavior of CollectionViewSource with grouping #2304

@DmitryProskurin

Description

@DmitryProskurin

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 Bug: ListView doesn't render its items when using CollectionViewSource & NativeAot #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions