Skip to content

Fix for SwipeView Command Binding Issue in CollectionView Templates#32790

Merged
StephaneDelcroix merged 2 commits intodotnet:inflight/currentfrom
BagavathiPerumal:fix-32332
Dec 2, 2025
Merged

Fix for SwipeView Command Binding Issue in CollectionView Templates#32790
StephaneDelcroix merged 2 commits intodotnet:inflight/currentfrom
BagavathiPerumal:fix-32332

Conversation

@BagavathiPerumal
Copy link
Contributor

@BagavathiPerumal BagavathiPerumal commented Nov 21, 2025

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!

Root Cause:

The issue is caused by a change to TemplateUtilities.OnContentChanged() that switched from using self.InternalChildren.RemoveAt()to self.RemoveAt(). This change removes all SwipeItems (RightItems, LeftItems, TopItems, BottomItems) from the logical children tree when the SwipeView template is applied. When SwipeItems are removed from the logical tree, RelativeSource bindings cannot traverse the parent chain to find ancestor ViewModels, causing command bindings to fail.

Regression PR: #30672

Fix Description:

The fix involves modifying TemplateUtilities.OnContentChanged to preserve SwipeItems when SwipeView content changes. When a SwipeView's Content property changes, the method selectively removes only the old content while preserving SwipeItems (RightItems, LeftItems, TopItems, BottomItems) in the logical tree using reference equality checks. This prevents SwipeItems from losing their binding context when content changes, ensuring RelativeSource bindings and commands continue to function correctly.

Issues Fixed

Fixes #32332

Tested the behaviour in the following platforms

  • Mac
  • Windows
  • iOS
  • Android

Output Screenshot

Before Issue Fix After Issue Fix
32332-BeforeFix.mov
32332-AfterFix.mov

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 21, 2025
… during content changes and updated the testcase.
@sheiksyedm sheiksyedm marked this pull request as ready for review November 24, 2025 13:20
Copilot AI review requested due to automatic review settings November 24, 2025 13:20
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 a regression where SwipeItem command bindings fail when SwipeView is used within CollectionView templates. The root cause was a change in PR #30672 that inadvertently removed SwipeItems from the logical tree when content changes, breaking RelativeSource bindings. The fix modifies TemplateUtilities.OnContentChanged to selectively preserve SwipeItems (RightItems, LeftItems, TopItems, BottomItems) in the logical tree during content changes, ensuring bindings continue to work correctly.

Key changes:

  • Modified TemplateUtilities.OnContentChanged to add SwipeView-specific logic that preserves SwipeItems during content changes
  • Updated device test to verify SwipeView maintains all 5 logical children (Content + 4 SwipeItems)
  • Added comprehensive unit test verifying SwipeItems remain in logical tree with proper parent relationships and binding context propagation

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Controls/src/Core/TemplateUtilities.cs Added SwipeView-specific logic to preserve SwipeItems in the logical tree when content changes, using reference equality checks to identify and retain the four SwipeItems collections
src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.cs Updated test assertion from expecting 1 logical child to 5 (Content + 4 SwipeItems), with clarifying comment
src/Controls/tests/Core.UnitTests/SwipeViewTests.cs Added comprehensive unit test verifying SwipeItems preservation in logical tree, including parent relationships, binding context propagation, and RelativeSource binding resolution

@sheiksyedm
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephaneDelcroix StephaneDelcroix changed the base branch from main to inflight/current December 2, 2025 15:29
@StephaneDelcroix StephaneDelcroix merged commit ab86f54 into dotnet:inflight/current Dec 2, 2025
161 of 169 checks passed
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…32790)

* fix-32332-Made the code changes to skip the child removal to preserve SwipeItems.

* fix-32332-Made the changes to preserve the SwipeItems in logical tree during content changes and updated the testcase.
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…32790)

* fix-32332-Made the code changes to skip the child removal to preserve SwipeItems.

* fix-32332-Made the changes to preserve the SwipeItems in logical tree during content changes and updated the testcase.
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…32790)

* fix-32332-Made the code changes to skip the child removal to preserve SwipeItems.

* fix-32332-Made the changes to preserve the SwipeItems in logical tree during content changes and updated the testcase.
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…32790)

* fix-32332-Made the code changes to skip the child removal to preserve SwipeItems.

* fix-32332-Made the changes to preserve the SwipeItems in logical tree during content changes and updated the testcase.
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…32790)

* fix-32332-Made the code changes to skip the child removal to preserve SwipeItems.

* fix-32332-Made the changes to preserve the SwipeItems in logical tree during content changes and updated the testcase.
@BagavathiPerumal BagavathiPerumal added the community ✨ Community Contribution label Dec 4, 2025
github-actions bot pushed a commit that referenced this pull request Dec 5, 2025
…32790)

* fix-32332-Made the code changes to skip the child removal to preserve SwipeItems.

* fix-32332-Made the changes to preserve the SwipeItems in logical tree during content changes and updated the testcase.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-swipeview SwipeView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binding the Swipe command in a SwipeView within a CollectionView template won't work in .NET 10 RC2.

4 participants