Add first item to a collapsed DataGrid can cause the window stuck for a few second
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use `dotnet --info`)
Many versions installed:
2.1.802 [C:\Program Files\dotnet\sdk]
3.1.201 [C:\Program Files\dotnet\sdk]
5.0.100-preview.1.20155.7 [C:\Program Files\dotnet\sdk]
I can repruduce this bug in 4.5, 4.7.2, 4.8, 3.0, 3.1
* Windows version: (`winver`)
10.0.18363
* Does the bug reproduce also in WPF for .NET Framework 4.8?:
Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
**Problem description:**
It's really a werid problem, I spent a few hours to determine the conditions to reproduce it.
Here are the key points:
1. The DataGrid.Visibility must bind to a property, and the value must be collapsed.
2. The DataGrid must be put in a Column in Grid whoes Width is auto.
3. The stuck time will be longer when DataGrid has more columns.
4. Add first item will cause the window stuck. Clear the ItemsSource and re-add one can cause, too.
Download the demo and run WpfApp1.exe, click the Add button, then the window stuck.
For more detail, please check the code.
The bug is orignally reported on [Developer Community](https://developercommunity.visualstudio.com/content/problem/991488/wpf-add-first-item-to-a-collapsed-datagrid-can-cau.html), they guide me here. The sample code is still there.
[SampleCode](https://developercommunity.visualstudio.com/storage/attachments/128735-wpfapp1.zip)
The original sample can not be downloaded anymore. I reuploaded one:
[WpfApp1.zip](https://github.com/dotnet/wpf/files/8213189/WpfApp1.zip)
**Actual behavior:**
The window stuck for a few seconds.
**Expected behavior:**
The window should not stuck
Contributor guide
Assessment
This issue has not been assessed yet.