Repository navigation
[release/10.0.1xx-sr10] Fix dynamic ContentPresenter assignment - #37725
Conversation
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
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37725Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37725" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
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/BorderHandlercontent update logic to detach an existingFrameworkElementfrom its current parent panel before assigning it to the newContentPanel. - 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
left a comment
There was a problem hiding this comment.
Adversarial review — independent reviewer
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
|
@PureWeen fixed in 361dcf5. Both Windows handlers now preserve the specialized |
PureWeen
left a comment
There was a problem hiding this comment.
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.
SR10.1 merge assessmentRecommendation: merge. Current head The remaining |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1e7f77e3-4862-4b92-a662-d12b5918bb59
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-sr10for .NET MAUI 10.0.101.6aa094eec8163fa3c1bcbf92041366da275b643e.inflight/currentand has not flowed tomain; this manual port intentionally excludes unrelated inflight branch history.Validation
32e617239637aca3c21818f22cc4304afe4bd65d.MakePri.exeon 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.