Skip to content

[release/10.0.1xx-sr10] Fix dynamic ContentPresenter assignment - #37725

Merged
kubaflo merged 2 commits into
dotnet:vs/10.0.101from
kubaflo:release-agent/sr10-backport-36430
Aug 22, 2026
Merged

kubaflo merged 2 commits into
dotnet:vs/10.0.101from
kubaflo:release-agent/sr10-backport-36430

Conversation

@kubaflo

@kubaflo kubaflo commented Aug 21, 2026

Copy link
Copy Markdown
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!

Summary

Manual backport of #36430 to release/10.0.1xx-sr10 for .NET MAUI 10.0.101.

Validation

  • Source and SR10 patches have matching stable patch ID 32e617239637aca3c21818f22cc4304afe4bd65d.
  • Local Windows cross-targeting reaches the Windows resource step but cannot execute Windows SDK MakePri.exe on macOS. The source PR was validated on Windows; the Windows CI lane is required for this backport.

Review gate

This agent-authored release PR must remain unmerged until two distinct non-bot MAUI maintainers with write access, other than the PR author, approve the current head SHA.

Manual backport of dotnet#36430 for .NET MAUI 10.0.101.

Source head: 6aa094e

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1e7f77e3-4862-4b92-a662-d12b5918bb59
Copilot AI lite review requested due to automatic review settings August 21, 2026 21:49
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 21, 2026 21:49 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37725

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37725"

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 21, 2026 21:49 — with GitHub Actions Inactive
@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 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 21, 2026 21:53 — with GitHub Actions Inactive
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 21, 2026 21:54 — with GitHub Actions Inactive
@github-actions github-actions Bot added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/windows labels Aug 21, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 21, 2026 21:55 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Backports the Windows fix for dynamically reassigning IContentView content (notably RefreshView/ScrollView scenarios) to release/10.0.1xx-sr10, preventing WinUI parent/ownership exceptions by safely detaching the existing platform element before reparenting. Adds a UI test + HostApp repro page to guard against regressions.

Changes:

  • Update Windows ContentViewHandler/BorderHandler content update logic to detach an existing FrameworkElement from its current parent panel before assigning it to the new ContentPanel.
  • Remove the prior DisconnectHandler-based “detach” approach to avoid breaking WinUI internal routing during content switches.
  • Add a HostApp issue page and a corresponding Appium UI test covering repeated content switching for issue #36298.

Reviewed changes

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

File Description
src/Core/src/Handlers/ContentView/ContentViewHandler.Windows.cs Detaches reused platform views from their current WinUI parent before reassigning content, avoiding WinUI reparenting exceptions.
src/Core/src/Handlers/Border/BorderHandler.Windows.cs Applies the same safe detach/reparent approach for Border content updates on Windows.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue36298.cs Adds an automated UI regression test to validate repeated content switching doesn’t crash.
src/Controls/tests/TestCases.HostApp/Issues/Issue36298.cs Adds a minimal repro page that switches between RefreshView and ScrollView content for the test to drive.

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adversarial review — independent reviewer

⚠️ Logic / Regression Prevention — Both Windows handlers detach an incoming platform view only when its current parent is ContentPanel or MauiPanel. A valid MAUI platform view can instead be parented by WrapperView, which is a plain WinUI Grid; this is why ViewHandlerOfT.Windows.cs already falls back to (Parent as Panel)?.Children. Moving such a wrapped view into a ContentView or Border leaves its existing parent intact, and the subsequent Content assignment can rethrow the same already-parented WinUI exception. Add a generic Panel.Children.Remove(fwElement) fallback after the specialized MAUI-panel cases in both handlers.

Consensus: 2/3 independent reviewers.

The added paired HostApp/Appium test is a meaningful regression test for the reported ContentPanel swap, but it does not exercise the non-MauiPanel parent path above. Existing review status: one prior COMMENTED automated review with no findings.

Fall back to Panel.Children when a reused platform view is parented by a non-MAUI WinUI panel, covering wrapped views in both ContentView and Border handlers.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: d00747b7-96f3-4e7a-8dfb-e3a48db04b2d
Copilot AI review requested due to automatic review settings August 21, 2026 23:10
@kubaflo

kubaflo commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

@PureWeen fixed in 361dcf5. Both Windows handlers now preserve the specialized ContentPanel/MauiPanel removal paths and fall back to Panel.Children.Remove for generic WinUI parents such as WrapperView. The exact fallback compiles against the pinned Windows App SDK with the required RS0030 scope; the full Windows build remains non-runnable on macOS because its native MakePri/XAML compiler executables cannot execute here. Ready for re-review — thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adversarial review — independent reviewer

No actionable issues found at 361dcf514e0126b4e63f63fd26b506b92824cbe5.

The parent-aware detach logic correctly handles ContentPanel, MauiPanel, and generic WinUI Panel parents without disconnecting the reused handler. The regression test provides a real observable content-switch assertion; the paired Border path uses the same ContentPanel reparenting mechanism, so a separate Border scenario is not required for this change.

3 independent reviewers with adversarial consensus + repo domain specialist. Prior generic-Panel feedback is addressed at this head.

@kubaflo

kubaflo commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

SR10.1 merge assessment

Recommendation: merge. Current head 361dcf514e is mergeable, and its completed current-head check set is 36 passed, 0 failed, 0 canceled, 1 skipped. No unresolved current review threads were found.

The remaining BLOCKED state is the required independent review. Because @kubaflo authored this PR, GitHub requires approval from a different maintainer; the authenticated account cannot self-approve it.

@kubaflo
kubaflo changed the base branch from release/10.0.1xx-sr10 to vs/10.0.101 August 22, 2026 14:40
@kubaflo
kubaflo merged commit a02bcc0 into dotnet:vs/10.0.101 Aug 22, 2026
37 checks passed
kubaflo added a commit that referenced this pull request Aug 22, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1e7f77e3-4862-4b92-a662-d12b5918bb59
This was referenced Sep 14, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 2026
@github-actions github-actions Bot added this to the .NET 11.0-rc2 milestone Oct 15, 2026
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 platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants