-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] CollectionView.EmptyView can not be removed by setting it to Null #18657
Copy link
Copy link
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewCollectionView, CarouselView, IndicatorViewp/2Work that is important, but is currently not scheduled for releaseWork that is important, but is currently not scheduled for releasepartner/hot-reload-xamlIssues impacting XAML Hot Reload experiencesIssues impacting XAML Hot Reload experiencespartner/hot-reload-xaml-full-page-fixedIssues with XAML incremental hot reload that are fixed after a full page hot reloadIssues with XAML incremental hot reload that are fixed after a full page hot reloadpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationplatform/windowss/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Milestone
Metadata
Metadata
Assignees
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewCollectionView, CarouselView, IndicatorViewp/2Work that is important, but is currently not scheduled for releaseWork that is important, but is currently not scheduled for releasepartner/hot-reload-xamlIssues impacting XAML Hot Reload experiencesIssues impacting XAML Hot Reload experiencespartner/hot-reload-xaml-full-page-fixedIssues with XAML incremental hot reload that are fixed after a full page hot reloadIssues with XAML incremental hot reload that are fixed after a full page hot reloadpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationplatform/windowss/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
In WinUI, If you try to programmatically remove an
EmptyViewon aCollectionViewby setting it to null, it will not be removed. The reference will be set to null in the CollectionView, but the actual View will still be present on the screen and in memory. Adding an item to the CollectionView invokes internal events within MAUI to remove the view, and users will not see it as it becomes hidden, but it's still present in the actual WinUI layout representation.Beyond memory and usage considerations, I believe this also leads to issues with VisualDiagnostics and Hot Reload. For example, if you try to remove an EmptyView with Hot Reload, it won't seem to work. If you add an item to the CollectionView, events are invoked in MAUI to say that the EmptyView was removed from the parent CollectionView, but the actual instance wasn't, leading to a bad state for VisualDiagnostics and the Live Visual Tree.
I've tested this on iOS, Catalyst, Android, and WinUI, and it only happens on WinUI.
Steps to Reproduce
In the output logs, you'll see that the view was set to StackLayout, then set to null. But the view is still on screen and not removed.
Link to public reproduction project repository
https://github.com/drasticactions/MauiRepros/tree/main/Finish
Version with bug
7.0.101
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response