Skip to content

Unexpected type for enumerator with CollectionViewSource #1733

@Foda

Description

@Foda

Describe the bug
WinAppSDK 1.6.240821007-preview2 crashes (Unexpected type for enumerator) when iterating over ListView.Items if the ListView.ItemsSource is set via CollectionViewSource.

To Reproduce

Sample to reproduce the crash:

var items = new List<string>
{
    "Item 1",
    "Item 2"
};

var source = new CollectionViewSource()
{
    Source = items
};
TheList.ItemsSource = source.View;

...

// Invoked via a button or something
foreach (var item in TheList.Items)
{
    // Crash
}

TheList is a simple ListView control.

Expected behavior
It shouldn't crash/throw an exception

Version Info

  • TargetFramework: net8.0-windows10.0.22621.0
  • TargetPlatformMinVersion: 10.0.17763.0
  • WindowsSdkPackageVersion: 10.0.22621.38
  • Microsoft.WindowsAppSDK package version: 1.6.240821007-preview2

Additional context
This is blocking WinAppSDK 1.6 version bump for .NET MAUI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions