Repository navigation
Conversation
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23566/wasm-skia-net9/index.html |
|
|
There was a problem hiding this comment.
Pull request overview
This PR aligns Uno’s UserControl inheritance with WinUI by reparenting it from ContentControl to Control, and reintroducing UserControl.Content as a UIElement-typed dependency property with direct single-child hosting. It also updates name lookup and hot-reload view swapping to account for the new hierarchy, adds runtime tests, and records the decision/implementation details in the breaking-changes spec.
Changes:
- Reparent
Microsoft.UI.Xaml.Controls.UserControlto inherit fromControland host content viaAddChild/RemoveChild. - Update
IFrameworkElement.FindNameand hot reloadSwapViewsto handleUserControl.Content. - Add
Given_UserControlruntime tests and reconcile the BC14 spec.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UI/UI/Xaml/IFrameworkElement.cs | Extends FindName search to include UserControl.Content when appropriate. |
| src/Uno.UI/UI/Xaml/Controls/UserControl/UserControl.Properties.cs | Introduces a UIElement-typed Content DP for UserControl. |
| src/Uno.UI/UI/Xaml/Controls/UserControl/UserControl.cs | Reparents UserControl to Control and swaps content via visual child add/remove. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_UserControl.cs | Adds runtime coverage for hierarchy and content hosting behavior. |
| src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.cs | Updates hot reload swapping to support UserControl as a parent. |
| specs/050-breaking-changes-rollup/bc14-usercontrol-to-control.md | Documents the resolved decision and implementation/validation notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23566/wasm-skia-net9/index.html |
1 similar comment
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23566/wasm-skia-net9/index.html |
|
|
0f24b56 to
e523ee1
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23566/wasm-skia-net9/index.html |
|
The build 220317 did not find any UI Test snapshots differences. |
|
|
Reparent UserControl from ContentControl directly onto Control to match the WinUI hierarchy (Control -> UserControl -> Page). UserControl now declares its own UIElement-typed Content and hosts a single visual child directly via AddChild/RemoveChild, dropping the ContentPresenter/template layer. Control's existing single-child layout handles measure/arrange. BREAKING CHANGE: UserControl and Page no longer inherit ContentControl. ContentTemplate, ContentTemplateSelector, ContentTransitions and the object-typed Content setter are removed; Content is now typed UIElement. 'x is ContentControl' against a UserControl/Page now returns false. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
FindName now descends into UserControl.Content (covers Page), since UserControl no longer matches the ContentControl branch. Hot reload's SwapViews gains a UserControl parent path so a UserControl-hosted child is swapped correctly. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Cover the WinUI-aligned hierarchy, UIElement-typed Content, ContentPresenter-less single-child rendering, content reassignment/removal, and DataContext flow through the visual tree. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Resolve the open decision (commit to WinUI parity), record the as-landed approach (AddChild/RemoveChild hosting, generated Content DP, no stub regeneration), note BC14 is independent of BC38, and capture validation status (Skia runtime done; parity/visual/WASM/hot-reload pending). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When_Content_Set asserted exact ActualWidth/Height; the WASM browser head rounds to a fractional-DPI device-pixel grid (50 -> 49.6), same artifact that affects the FrameworkElement clip/arrange tests. Assert within 1px tolerance to keep the intent (child laid out via Control's single-child layout) robust across heads. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Declare [ContentProperty(Name = nameof(Content))] on the hand-written UserControl partial and drop it from the generated partial, matching the ContentControl/Border convention. ContentPropertyAttribute is AllowMultiple = false, so keeping it on both partials would be a CS0579 duplicate-attribute error. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When_Color_Thickness_GridLength_As_String loads a UserControl-rooted XAML and cast the result to ContentControl. Since UserControl no longer inherits ContentControl, the cast yields null and the test NRE'd. UserControl exposes Resources (FrameworkElement) and Content, so the assertions resolve unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The nested-DataTemplate hot-reload fixtures host a plain MyControl as a Page's content. Page.Content (via UserControl) is now UIElement-typed instead of object, so the generated `base.Content = new MyControl()` no longer compiled (CS0029). Deriving MyControl from Control keeps it assignable while preserving its [ContentProperty] DataTemplate slots. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A sample whose IWaitableSample.SamplePreparedTask never completes would block the entire auto-screenshot walk until the CI job timeout (observed on ImageBrush_StreamSource). Cap the wait at 30s and log the offending sample so a single stuck sample yields one bad screenshot instead of hanging the whole job. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Assigning an already-decoded BitmapImage to MySource can raise ImageOpened/ImageFailed synchronously via x:Bind, so subscribing after the assignment missed those events, leaving _tcs incomplete and hanging the snapshot run on this IWaitableSample. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
e523ee1 to
b8552a2
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23566/wasm-skia-net9/index.html |
|
The build 220331 did not find any UI Test snapshots differences. |
GitHub Issue: closes unoplatform/uno-private#2054
Part of the breaking-changes rollup epic #8339 (item BC14).
PR Type:
✨ Feature (breaking change — see migration note below)
What changed? 🚀
Reparents
UserControlfromContentControldirectly ontoControl, matching the WinUI hierarchyControl→UserControl→Page. Uno previously inserted an extraContentControllayer (Control→ContentControl→UserControl→Page).UserControl : Controlwith its ownUIElement-typedContent([GeneratedDependencyProperty],AffectsMeasure | ValueDoesNotInheritDataContext). Single-child hosting is done directly viaAddChild/RemoveChildinOnContentChanged— noContentPresenter/ContentTemplateplumbing.Control's existing single-child layout (FindFirstChild/ArrangeFirstChild) handles measure/arrange, soUserControladds no layout overrides and no per-platform partial.Pageinherits the new base unchanged; itsOnBackgroundChangedoverride still works.IFrameworkElement.FindNamegained aUserControl.Contentbranch (coversPage); hot reload'sSwapViewsgained aUserControlparent path. Otheris ContentControlsites correctly stop matchingUserControl/Page(the WinUI-aligned behavior) and needed no change.UserControl/Pagestubs already matched the target shape, so no regeneration was required.Benefits: true WinUI parity for the most-subclassed control, lighter/faster visual trees (a
ContentPresenter/template layer dropped from everyUserControlandPage), andContentcorrectly typedUIElement.Validation
Given_UserControlruntime tests (hierarchy,UIElementContent, ContentPresenter-less single-child rendering, reassignment/removal, DataContext-through-tree).Given_UserControl5/5; regression batch acrossGiven_Control/Given_ContentControl(incl. FindName)/Given_ContentPresenter/Given_Frame(navigation)/Given_VisualStateManager/Given_FocusManager/Given_FrameworkElement= 407 passed / 0 failed.Given_UserControl5/5 (assertion relaxed for the WASM fractional-DPI device-pixel grid).Given_UserControl5/5 — confirms parity with the reference implementation.UserControl/Pagecontent hosting — background/border/padding/centered content render correctly; theming cascades through the directly-hosted child.PR Checklist ✅
Given_UserControl), validated on Skia Desktop, WASM, and native WinUIspecs/050-breaking-changes-rollup/bc14-usercontrol-to-control.md)Screenshots Compare Test Runresults (to review once CI runs)Breaking change — impact & migration
UserControlandPageno longer inheritContentControl:ContentTemplate,ContentTemplateSelector,ContentTransitions, and theobject-typedContentsetter are removed fromUserControl/Page.Contentis now typedUIElement(matching WinUI). Code/XAML setting those members on aUserControl/Pagemust be updated.x is ContentControl/ContentControl-typed casts against aUserControl/Pagenow evaluatefalse. Code relying on this must targetControl/UserControl(or the concrete type) instead.This matches WinUI exactly, so apps already written against the WinUI surface are unaffected. Ships last in its own stabilized PR per the epic plan; never batched.