Skip to content

Conversation

@devanathan-vaithiyanathan
Copy link
Contributor

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

When the Header or Footer is set to null at runtime, empty space remains in the layout because their heights are still included while calculating the EmptyView frame.

Description of Change

Added cleanup logic for header and footer views in UpdateHeaderView and UpdateFooterView methods.
When the Header or Footer (or their templates) are set to null, the corresponding native views are now removed from the CollectionView using their assigned tags.

Issues Fixed

Fixes #31899

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac

Output Screenshot

Before After
iOS
Before.mov
iOS
After.mov

@dotnet-policy-service
Copy link
Contributor

Hey there @@devanathan-vaithiyanathan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Oct 8, 2025
@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Oct 9, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@devanathan-vaithiyanathan devanathan-vaithiyanathan marked this pull request as ready for review October 10, 2025 12:29
Copilot AI review requested due to automatic review settings October 10, 2025 12:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where removing a header or footer from a CollectionView at runtime on iOS/macOS left empty space that was still being included in EmptyView frame calculations. The fix adds proper cleanup logic to remove the native views when their content is set to null.

  • Added cleanup methods in StructuredItemsViewController2 to remove header/footer views when content is null
  • Uncommented and activated existing UpdateHeaderView/UpdateFooterView calls in the handler
  • Added comprehensive UI test coverage for both removing and adding header/footer at runtime

Reviewed Changes

Copilot reviewed 4 out of 9 changed files in this pull request and generated 1 comment.

File Description
src/Controls/src/Core/Handlers/Items2/iOS/StructuredItemsViewController2.cs Added UpdateHeaderView and UpdateFooterView methods to remove native views when content is null
src/Controls/src/Core/Handlers/Items2/CollectionViewHandler2.iOS.cs Uncommented calls to UpdateHeaderView and UpdateFooterView methods
src/Controls/tests/TestCases.HostApp/Issues/Issue31899.cs Added UI test page demonstrating header/footer toggle functionality
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31899.cs Added automated tests for header/footer removal and addition scenarios

Comment on lines +74 to +80
return new Label
{
TextColor = Colors.Black,
FontSize = 16,
// This binding works with string items
BindingContext = "{Binding .}"
};
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting BindingContext to a string literal instead of using the SetBinding method. This should be SetBinding(Label.TextProperty, new Binding(".")) or use a proper binding syntax.

Suggested change
return new Label
{
TextColor = Colors.Black,
FontSize = 16,
// This binding works with string items
BindingContext = "{Binding .}"
};
var label = new Label
{
TextColor = Colors.Black,
FontSize = 16,
};
label.SetBinding(Label.TextProperty, new Binding("."));
return label;

Copilot uses AI. Check for mistakes.
@PureWeen PureWeen added the p/0 Current heighest priority issues that we are targeting for a release. label Oct 10, 2025
@PureWeen PureWeen added this to the .NET 10 SR1 milestone Oct 10, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Oct 10, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Oct 21, 2025
@PureWeen PureWeen changed the base branch from main to inflight/candidate October 31, 2025 20:33
@PureWeen PureWeen merged commit 410ccaf into dotnet:inflight/candidate Oct 31, 2025
79 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Oct 31, 2025
github-actions bot pushed a commit that referenced this pull request Nov 4, 2025
…d EmptyView not resized in CollectionView (#31916)

* Update StructuredItemsViewController2.cs

* fix updated

* Test case added

* Update StructuredItemsViewController2.cs

* Update Issue31899.cs

* Update Issue31899.cs

* Test fail changes updated

* Order value changed

* Added snapshots
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution p/0 Current heighest priority issues that we are targeting for a release. partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[CV2] Header/Footer removed at runtime leaves empty space and EmptyView not resized in CollectionView

3 participants