Skip to content

[inflight/candidate] [Windows] Fix Device test failing in the PR 37746 - #38021

Merged
kubaflo merged 1 commit into
dotnet:inflight/candidatefrom
devanathan-vaithiyanathan:fix-36430-candidate-failure
Aug 31, 2026
Merged

kubaflo merged 1 commit into
dotnet:inflight/candidatefrom
devanathan-vaithiyanathan:fix-36430-candidate-failure

Conversation

@devanathan-vaithiyanathan

Copy link
Copy Markdown
Contributor

Issue Details

On Windows, dynamically updating the content of a ContentPresenter can throw a System.ArgumentException when the content contains controls such as RefreshView or ScrollView.

This happens when a platform view is reused while it is still attached to its previous WinUI parent, causing a “PointerEventRouter object already has an owner” exception.

The initial fix detached the platform view from its previous parent, but some scenarios still failed because:

  • The logical content was not detached before creating the control-template platform tree.
  • ContentPanel.Content = null could leave stale children in CachedChildren.

Description of Change

Description of Change

Updated the Windows ContentViewHandler content-update flow to properly handle direct, templated, and empty content.

  • Detach the existing content before creating the template platform tree.
  • Added a RemoveFromParent helper to safely detach the incoming platform view without disconnecting its handler.
  • Clear ContentPanel.CachedChildren before assigning new content or when the content becomes null.

Fixed below test cases:
Control.DeviceTests:

  • ControlTemplateInitializesCorrectly
  • ControlTemplateCanBeReplacedCorrectly
  • ContentView updating it's ControlTemplate works
  • PropagateContextCorrectly

Core.DeviceTests:

  • Content Initializes Correctly
  • Content Updates Correctly
  • ContentIsSetInitially
  • WindowSupportsEmptyPage_Platform

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 31, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@vishnumenon2684 vishnumenon2684 added the community ✨ Community Contribution label Aug 31, 2026
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman changed the title [Windows-inflight/candidate] Fix Device test failing in the PR 37746 [inflight/candidate] [Windows] Fix Device test failing in the PR 37746 Aug 31, 2026
@github-actions github-actions Bot added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/windows labels Aug 31, 2026
@sheiksyedm
sheiksyedm marked this pull request as ready for review August 31, 2026 06:32
@sheiksyedm
sheiksyedm requested a review from kubaflo August 31, 2026 06:32
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo
kubaflo merged commit 56a82dc into dotnet:inflight/candidate Aug 31, 2026
15 of 19 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR11 milestone Aug 31, 2026
kubaflo pushed a commit that referenced this pull request Sep 3, 2026
#38021)

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details
On Windows, dynamically updating the content of a ContentPresenter can
throw a System.ArgumentException when the content contains controls such
as RefreshView or ScrollView.
 
This happens when a platform view is reused while it is still attached
to its previous WinUI parent, causing a “PointerEventRouter object
already has an owner” exception.

The initial fix detached the platform view from its previous parent, but
some scenarios still failed because:
* The logical content was not detached before creating the
control-template platform tree.
* ContentPanel.Content = null could leave stale children in
CachedChildren.

### Description of Change

<!-- Enter description of the fix in this section -->
### Description of Change

<!-- Enter description of the fix in this section -->
Updated the Windows ContentViewHandler content-update flow to properly
handle direct, templated, and empty content.
* Detach the existing content before creating the template platform
tree.
* Added a RemoveFromParent helper to safely detach the incoming platform
view without disconnecting its handler.
* Clear ContentPanel.CachedChildren before assigning new content or when
the content becomes null.

Fixed below test cases:
Control.DeviceTests:
* ControlTemplateInitializesCorrectly 
* ControlTemplateCanBeReplacedCorrectly 
* ContentView updating it's ControlTemplate works 
* PropagateContextCorrectly

Core.DeviceTests:

* Content Initializes Correctly
* Content Updates Correctly
* ContentIsSetInitially
* WindowSupportsEmptyPage_Platform
kubaflo pushed a commit that referenced this pull request Sep 4, 2026
#38021)

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details
On Windows, dynamically updating the content of a ContentPresenter can
throw a System.ArgumentException when the content contains controls such
as RefreshView or ScrollView.
 
This happens when a platform view is reused while it is still attached
to its previous WinUI parent, causing a “PointerEventRouter object
already has an owner” exception.

The initial fix detached the platform view from its previous parent, but
some scenarios still failed because:
* The logical content was not detached before creating the
control-template platform tree.
* ContentPanel.Content = null could leave stale children in
CachedChildren.

### Description of Change

<!-- Enter description of the fix in this section -->
### Description of Change

<!-- Enter description of the fix in this section -->
Updated the Windows ContentViewHandler content-update flow to properly
handle direct, templated, and empty content.
* Detach the existing content before creating the template platform
tree.
* Added a RemoveFromParent helper to safely detach the incoming platform
view without disconnecting its handler.
* Clear ContentPanel.CachedChildren before assigning new content or when
the content becomes null.

Fixed below test cases:
Control.DeviceTests:
* ControlTemplateInitializesCorrectly 
* ControlTemplateCanBeReplacedCorrectly 
* ContentView updating it's ControlTemplate works 
* PropagateContextCorrectly

Core.DeviceTests:

* Content Initializes Correctly
* Content Updates Correctly
* ContentIsSetInitially
* WindowSupportsEmptyPage_Platform
@kubaflo kubaflo mentioned this pull request Sep 6, 2026
5 of 8 tasks
kubaflo pushed a commit that referenced this pull request Sep 7, 2026
#38021)

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details
On Windows, dynamically updating the content of a ContentPresenter can
throw a System.ArgumentException when the content contains controls such
as RefreshView or ScrollView.
 
This happens when a platform view is reused while it is still attached
to its previous WinUI parent, causing a “PointerEventRouter object
already has an owner” exception.

The initial fix detached the platform view from its previous parent, but
some scenarios still failed because:
* The logical content was not detached before creating the
control-template platform tree.
* ContentPanel.Content = null could leave stale children in
CachedChildren.

### Description of Change

<!-- Enter description of the fix in this section -->
### Description of Change

<!-- Enter description of the fix in this section -->
Updated the Windows ContentViewHandler content-update flow to properly
handle direct, templated, and empty content.
* Detach the existing content before creating the template platform
tree.
* Added a RemoveFromParent helper to safely detach the incoming platform
view without disconnecting its handler.
* Clear ContentPanel.CachedChildren before assigning new content or when
the content becomes null.

Fixed below test cases:
Control.DeviceTests:
* ControlTemplateInitializesCorrectly 
* ControlTemplateCanBeReplacedCorrectly 
* ContentView updating it's ControlTemplate works 
* PropagateContextCorrectly

Core.DeviceTests:

* Content Initializes Correctly
* Content Updates Correctly
* ContentIsSetInitially
* WindowSupportsEmptyPage_Platform
kubaflo added a commit that referenced this pull request Sep 11, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## What's Coming

This draft promotes the current `inflight/candidate` contents into
`main` for the .NET 10 SR11 (`10.0.110`) candidate cycle.

## Candidate Snapshot

- Initial source: `inflight/current`, followed by candidate-specific
stabilization and approved backports
- Rebased onto `main`:
[`b96aa036`](b96aa03)
- Current candidate head:
[`b643a7e3`](b643a7e)
- Final candidate commits relative to `main`: [111
commits](b96aa03...inflight/candidate)
- Rebase accounting: all 111 pre-rebase commits map exactly to 111
rebased commits, with no modified, dropped, or added patches
- Patch version: `110`
- PR #37033 remains intentionally excluded because it merged into
`inflight/current` after the initial candidate cut.

## Stabilization Since the Initial Cut

- #37669 fixes the MauiBlazorWebView device-test build.
- #37672 reverts unstable iOS and Mac Catalyst leak tests.
- #37810 reverts the iOS wrapped-scroll-content large-title change.
- #37837 completes iOS `ScrollView` requests inside collapsed branches.
- #37438 updates the first set of candidate test failures.
- #38021 fixes the Windows `ContentPresenter` device-test regression;
its patch is now supplied by `main`.
- #38096 reverts the Accelerometer weak-event change.
- #38126 backports the BlazorWebView and HybridWebView fixes.
- #38028 updates the remaining candidate test failures and stale iOS
snapshots.

## Rebase Validation

- [x] Commit accounting: 111 exact mappings with no modified, dropped,
or added patches
- [x] Independent reference merge and rebased branch have the identical
tree ID `3e10281363c889cbafd4de790911efb0ae365e2a`
- [x] BuildTasks succeeds with 0 warnings and 0 errors across the
restored Android, iOS, Mac Catalyst, and .NET targets
- [x] All 39 focused `ScrollViewUnitTests` pass
- [x] No merge commits, conflict markers, or new whitespace warnings;
the 26 existing whitespace warnings remain unchanged
- [ ] Post-rebase `maui-pr`, `maui-pr-devicetests`, and
`maui-pr-uitests` runs complete
- [ ] Candidate-only build and test failures triaged
- [ ] Release-readiness assessment completed

This PR remains a draft while candidate validation and stabilization
continue.

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 1, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 0fed535b Deployed Aug 31, 2026 by devanathan-vaithiyanathan via conclusion #1638
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants