maui
maui copied to clipboard
Fixed CollectionView.EmptyView can not be removed by setting it to Null
[!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Details
In WinUI, setting the CollectionView's EmptyView to null does not fully remove the associated visual element. While the reference is cleared, the view remains in the visual tree and memory, leading to an inconsistent UI state.
Root Cause
When EmptyView was set to null, the handler exited early without performing the necessary cleanup. As a result, the visual element persisted in the UI tree and memory.
Description of Change
The logic now explicitly collapses the EmptyView's visibility when applicable and removes it from the logical tree to ensure it is detached from the visual hierarchy. Internal references are cleared, and the display flag is reset to maintain an accurate UI state.
#29463 - Issue 1: EmptyView Template is Not Displayed
Root Cause
The EmptyViewTemplate was not considered in the UpdateEmptyView, causing it to be ignored.
Description of Change
The EmptyViewTemplate is now properly managed to ensure it appears when appropriate.
Validated the behaviour in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [X] Mac
Issues Fixed:
Fixes #18657 Fixes #29463
Screenshots
| Before | After |
|---|---|
/azp run MAUI-UITests-public
Azure Pipelines successfully started running 1 pipeline(s).
/azp run MAUI-UITests-public
Azure Pipelines successfully started running 1 pipeline(s).
These tests:
Seems to be crashing on Windows.
The app was expected to be running still, investigate as possible crashCould you review if are related with the changes?
@jsuarezruiz Currently looking into the CI test failure on Windows.
These tests:
Seems to be crashing on Windows.
The app was expected to be running still, investigate as possible crashCould you review if are related with the changes?
@jsuarezruiz Fixed CI failure. Could you please review it once.
/azp run MAUI-UITests-public
Azure Pipelines successfully started running 1 pipeline(s).

