CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.89k stars 1.38k forks source link

DataGrid does not display new data when the source is grouped #4574

Open KiruyaMomochi opened 2 years ago

KiruyaMomochi commented 2 years ago

Describe the bug

I'm using a grouped collection as source of DataGrid and inserted a new group of data into the collection. When I added new data to this new group, these data didn't show up in DataGrid.

Regression

No response

Reproducible in sample app?

Steps to reproduce

  1. Create a WinUI 3 app using Template Studio.
  2. Create XAML file GroupedDataGridPage.xaml

    XAML file ```xml
  3. Create code behind GroupedDataGridPage.xaml.cs

    Code behind XAML ```csharp using System.Collections.ObjectModel; using CommunityToolkit.WinUI.UI.Controls; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; namespace Kyaru.Views; public class GroupInfoCollection: ObservableCollection { public string Key { get; set; } } public class SampleModel { public string Name { get; set; } = "Name"; } public partial class GroupedDataGridPage: Page { public ObservableCollection> SampleData { get; set; } = new(); public GroupedDataGridPage() { InitializeComponent(); } private void AddBeforeButton_OnClick(object sender, RoutedEventArgs e) { var group = new GroupInfoCollection { Key = "Key" }; group.Add(new (){ Name = "a" }); group.Add(new (){ Name = "b" }); SampleData.Add(group); } private void AddAfterButton_OnClick(object sender, RoutedEventArgs e) { var group = new GroupInfoCollection { Key = "Key" }; SampleData.Add(group); group.Add(new (){ Name = "a" }); group.Add(new (){ Name = "b" }); } } ```
  4. Add our newly created page to navigation, and run the app
  5. Click AddBefore, a new group is created. DataGrid says (2 items), but shows nothing.
  6. Click AddAfter, another new group is created. DataGrid says (0 items), but shows 2 items.
  7. The GridView below always has the correct behavior.

Expected behavior

Both AddBefore and AddAfter should gives a group that says (2 items) and show 2 items in it.

Screenshots

image

Windows Build Number

Other Windows Build number

Windows 11 Insider Preview (Build 25131)

App minimum and target SDK version

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

N/A (Using dotnet run, with patch from dotnet/maui)

Device form factor

No response

Nuget packages

Additional context

No response

Help us help you

Yes, but only if others can assist.

ghost commented 2 years ago

Hello KiruyaMomochi, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌