Repository navigation
Build Reactor's DataTemplates from code instead of parsing markup - #1125
Draft
Alexandre Zollinger Chohfi (azchohfi) wants to merge 4 commits into
Draft
Alexandre Zollinger Chohfi (azchohfi) wants to merge 4 commits into
Alexandre Zollinger Chohfi (azchohfi) wants to merge 4 commits into
Conversation
Contributor
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
Contributor
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
No size change beyond the noise floor. ✅ ✅ smaller / |
Alexandre Zollinger Chohfi (azchohfi)
force-pushed
the
azchohfi-winui3-integration-datatemplate
branch
from
August 25, 2026 22:30
9cfd5c5 to
7b0195f
Compare
Alexandre Zollinger Chohfi (azchohfi)
force-pushed
the
azchohfi-winui3-integration-datatemplate
branch
from
October 5, 2026 22:17
7b0195f to
e2c19e1
Compare
Alexandre Zollinger Chohfi (azchohfi)
force-pushed
the
azchohfi-winui3-integration-datatemplate
branch
from
October 15, 2026 22:10
e2c19e1 to
a93e826
Compare
Alexandre Zollinger Chohfi (azchohfi)
force-pushed
the
azchohfi-winui3-integration-datatemplate
branch
7 times, most recently
from
November 10, 2026 17:07
163dd8e to
6ddd295
Compare
Alexandre Zollinger Chohfi (azchohfi)
force-pushed
the
azchohfi-winui3-integration-datatemplate
branch
6 times, most recently
from
November 17, 2026 18:28
151c75c to
2dfaa00
Compare
Alexandre Zollinger Chohfi (azchohfi)
force-pushed
the
azchohfi-winui3-integration-datatemplate
branch
3 times, most recently
from
November 19, 2026 17:53
d6b1318 to
219f9e7
Compare
7 tasks done
Alexandre Zollinger Chohfi (azchohfi)
added this pull request to stack #1619
November 19, 2026 23:32
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Nov 19, 2026
…rsed Style
ApplyThemeBindings built a {ThemeResource} Style as a XAML string, parsed it
with XamlReader.Load, cached it, and assigned fe.Style, which replaced any
Style the app had set. It now calls FrameworkElement.SetThemeResourceBinding
(experimental WinUI API, available on the 2.6.6-experimental channel #1125
moves to) once per property, tracking what it bound on the control's
ReactorState.
The binding sits at local precedence, where the Style sat below it, so the
old winners are preserved explicitly: an explicit brush modifier wins in
either call order, and a local value Reactor did not bind (a .Set setter, an
element property) is left alone. A live binding is not re-installed on an
ordinary render, only on a resource-refresh pass (Theme.NotifyResourcesChanged),
which needs re-resolution of an edited dictionary entry.
InteractionStates used to restore a themed border brush by clearing its local
value so the Style showed through. With the binding now being that local
value, the restore re-installs the binding instead.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0008bac9-a08b-4ee8-9f96-505c6f6f28b0
This was referenced Nov 20, 2026
Alexandre Zollinger Chohfi (azchohfi)
force-pushed
the
azchohfi-winui3-integration-datatemplate
branch
from
November 20, 2026 17:08
219f9e7 to
57a068b
Compare
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Nov 20, 2026
…rsed Style
ApplyThemeBindings built a {ThemeResource} Style as a XAML string, parsed it
with XamlReader.Load, cached it, and assigned fe.Style, which replaced any
Style the app had set. It now calls FrameworkElement.SetThemeResourceBinding
(experimental WinUI API, available on the 2.6.6-experimental channel #1125
moves to) once per property, tracking what it bound on the control's
ReactorState.
The binding sits at local precedence, where the Style sat below it, so the
old winners are preserved explicitly: an explicit brush modifier wins in
either call order, and a local value Reactor did not bind (a .Set setter, an
element property) is left alone. A live binding is not re-installed on an
ordinary render, only on a resource-refresh pass (Theme.NotifyResourcesChanged),
which needs re-resolution of an edited dictionary entry.
InteractionStates used to restore a themed border brush by clearing its local
value so the Style showed through. With the binding now being that local
value, the restore re-installs the binding instead.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0008bac9-a08b-4ee8-9f96-505c6f6f28b0
Reactor built two DataTemplates at runtime by handing XamlReader.Load a markup
string: the ContentControl shell every items control mounts
(ListView/GridView/FlipView), and the legacy text-node TreeView template. Both
existed only because DataTemplate could not be constructed from code.
WinUI now offers `new DataTemplate(DataTemplateElementFactory)`, which takes a
callback returning the subtree. This ports both templates onto it, so Reactor
no longer parses XAML at runtime for item templates.
Beyond removing the parse, the TreeView template loses its
`{Binding Content.Content}`. A classic Binding resolves that path by string
through CsWinRT's ICustomPropertyProvider -- reflection, which NativeAOT trims
unless the source type is annotated, and which costs a reflective lookup per
realized row even when it works. Reading the same chain in a
DataContextChanged handler is strongly typed: no annotation, no lookup, and the
event re-fires on recycling so reused rows retext correctly.
Windows App SDK versions move to the public experimental channel. The API is on
nuget.org but still carries [feature(Feature_ExperimentalApi)], so it exists
only there: it landed in Microsoft.WindowsAppSDK.WinUI 2.3.10-experimental and
is absent from 2.3.9 stable. The 2.5.4-experimental metapackage is the aggregate
that pairs with it (its nuspec names WinUI 2.3.10-experimental and pins Runtime
[2.5.4-experimental]), so the pairing rule in spec 063 section 3 is satisfied
and no package-reference workaround is needed.
Two incidental fixes this SDK requires:
* CS8305 is demoted from error to warning. The XAML compiler's *generated*
XamlTypeInfo.g.cs references the SDK's own experimental metadata providers
(XamlControlsCharts/XamlControlsTabular), so every WinUI project emits it
from code we do not own. WarningsNotAsErrors rather than NoWarn, so a
newly-introduced experimental dependency is still reported.
* The IElementFactory cref in IItemsRepeaterFactorySource is disambiguated.
This SDK adds Microsoft.UI.Xaml.IElementFactory alongside the existing
Microsoft.UI.Xaml.Controls.IElementFactory, making the bare cref ambiguous
(CS0419) and failing the warnings-as-errors Release build. Verified still
required: restoring the bare cref reproduces the error.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 17bce8bb-d57a-4f76-a55d-27c9029fc9a3
#1108 annotated TreeViewNodeData with [WinRT.GeneratedBindableCustomProperty] for exactly one reason: Reactor's own text-node TreeView template bound "Content.Content", and that string path is resolved by reflection, which NativeAOT trims. The preceding commit replaces that binding with a DataContextChanged handler, so the reason is gone -- there is now no {Binding} anywhere in src/ and no SetBinding call site. The attribute never shipped: every tag to date predates #1108, so no released build has it, and binding to TreeViewNodeData from a consumer-supplied template was already broken under NativeAOT in all of them. Removing it therefore takes away nothing that ever worked in a release; it declines to keep a side effect of an internal fix. Keeping it would carry a workaround, plus `partial` on a public record, for a scenario Reactor does not use and does not document. The limitation is written down instead: docs/aot-support.md gains a row explaining that a classic {Binding} in a hand-supplied DataTemplate is not trim-safe, that Reactor's own templates avoid it by populating content in a DataContextChanged handler, and that a consumer installing their own template through an escape hatch should do the same or annotate their own type. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 17bce8bb-d57a-4f76-a55d-27c9029fc9a3
The experimental channel broke nine CI jobs. None needed a workflow restructure; each had a narrow cause. * Doc snippet analyzer gate: the CS8305 exception for the SDK's generated XamlTypeInfo.g.cs lived in WarningsNotAsErrors, but this job passes -p:WarningsNotAsErrors=NU1900 on the command line, and a global property replaces the project value. Moved to an .editorconfig severity scoped to **/XamlTypeInfo.g.cs, which global properties cannot clobber. Narrower too: CS8305 still fires on Reactor's own experimental API use (verified with a probe file). * REACTORGEN016 (added later by #1583): Microsoft.WinUI on this channel ships three XAML metadata providers (Charts and Tabular are the same experimental ones behind CS8305; stable ships one), so the wrapper generator cannot pick a unique provider for wrappers of built-in WinUI controls and warns, which Release turns into an error. Its fallback, TryRegisterControlAssembly, is what every wrapper emitted before #1583. Downgraded to a suggestion for tests/ and samples/ in .editorconfig; main's Release build has no REACTORGEN016, so this hides nothing else. * Literal SDK pin guard: bumped the 25 literal Microsoft.WindowsAppSDK pins (recipes, SKILL.md, CLI scaffold, perf script, samples) to the central 2.5.4-experimental. These ship in the agent kit, so this branch must stay a draft until the API graduates to stable. * Motion parity guard: re-verified, not bumped blindly. The four WinUI motion sources have identical blob SHAs at winui3/release/2.2.0 and winui3/release/2.5.4-experimental; the tag compare is non-empty (300 files) as a positive control. The new tag is rooted at the repository root rather than under src/, so the guard's path-prefix advice is generalized. * Roaming-hive guard: its trigger fired for real. Measured on the bundled runtime (Foundation 2.3.13-experimental, loaded from bin\): LocalSettings now writes the machine-local hive, i.e. WindowsAppSDK#6559 is fixed. The control now requires the value in exactly one hive, and the store is asserted absent from both. The spec 063 D1 follow-up is now actionable. Coverage jobs failed on the same unit guards and are fixed by the above. bootstrap needs no change: since template pack 0.0.8-alpha the reactor templates carry no Microsoft.WindowsAppSDK reference, so the scaffolded app takes the SDK transitively from the local Reactor package. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 17bce8bb-d57a-4f76-a55d-27c9029fc9a3
The 2.6 experimental release (published 2026-11-07) supersedes
2.5.4-experimental. Its metapackage nuspec pairs it with
Microsoft.WindowsAppSDK.WinUI 2.6.6-experimental and exact-pins
Runtime [2.6.6-experimental], so both central values move together per the
spec 063 pairing rule. The code-based DataTemplate constructor is still
[VelocityFeature("Feature_ExperimentalApi")] on microsoft-ui-xaml main, and
absent from every stable WinUI through 2.6.5, so this stays on the
experimental channel.
The 24 literal pins move with the central version, as the literal-pin guard
requires (draft-only: they ship in the agent kit and must go to a stable
version at graduation).
Motion-parity guard re-verified by bracketing, because no
winui3/release/2.6.6-experimental source tag is published yet: the four
motion sources have identical blob SHAs at 2.5.4-experimental, 2.6.4 stable
and main, while 2.5.4-experimental..main changes 300 files.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 17bce8bb-d57a-4f76-a55d-27c9029fc9a3
Alexandre Zollinger Chohfi (azchohfi)
force-pushed
the
azchohfi-winui3-integration-datatemplate
branch
from
November 21, 2026 17:12
57a068b to
6ba6a55
Compare
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Nov 21, 2026
…rsed Style
ApplyThemeBindings now binds each mapped property (Background, Foreground,
BorderBrush, SplitView.PaneBackground) with FrameworkElement.SetThemeResourceBinding,
the code equivalent of {ThemeResource}, instead of building a Style from a XAML
string. Ownership is tracked per property in ReactorState.ThemeResourceBindings, so
a dropped ThemeRef or a pooled control clears only what Reactor bound, and the
precedence the old Style had (explicit brush modifiers, setters and element
properties win) is kept at local-value precedence.
This replaces the Style path PR #1636 shipped on the stable SDK and keeps its
behavior checks (ThemeRefStyleFixtures). Removed with it: the themed-Style caches,
the ownership marker, the BasedOn base-style stamping and fallback, the
DefaultSplitViewStyle workaround and the unrepresentable-key warning, since no
Style is written and a key needs no quoting. FormatThemeResourceReference stays
for ThemeResourceProbe. InteractionStates keeps main's restore and also puts back
a theme binding the state wrote over, instead of its resolved brush. A key that
changes to one WinUI can't find now releases the property instead of keeping the
previous key's brush.
Stacks on #1125 (experimental Windows App SDK).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0008bac9-a08b-4ee8-9f96-505c6f6f28b0
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Still draft — but the blocker changed. The code-based
DataTemplateconstructor is now on nuget.org, so this branch no longer needs an internal build and CI can restore it. What now keeps it in draft is the cost of the channel, not availability: see Why this still cannot merge.What this does
Reactor built two
DataTemplates at runtime by handingXamlReader.Loada markup string:SharedContentControlTemplate— theContentControlshell every items control mounts (ListView / GridView / FlipView)TreeViewTextItemTemplate— the legacy text-node TreeView item templateBoth existed only because
DataTemplatecould not be constructed from code. WinUI now offersnew DataTemplate(DataTemplateElementFactory), which takes a callback returning the subtree, so this ports both onto it and Reactor stops parsing XAML at runtime for item templates.The part that is more than cosmetic
The TreeView template also loses its
{Binding Content.Content}.A classic
{Binding}resolves that path by string, through CsWinRT'sICustomPropertyProvider— i.e. reflection. It is trimmed away under NativeAOT unless the source type carries generated binding metadata, and even where it works it costs a reflective lookup per realized row.Reading the same chain in a
DataContextChangedhandler is strongly typed:No metadata required, no reflective lookup, and the event re-fires when a virtualized row is recycled onto new data, so reused rows retext correctly. (
x:Bindis not an option — it is a XAML-compiler feature, unavailable from a code-built subtree.)Because that was the only
{Binding}Reactor had,[WinRT.GeneratedBindableCustomProperty]onTreeViewNodeData— added by #1108 purely to keep it trim-safe — is removed along with thepartialit forced onto a public record. There is now no{Binding}anywhere insrc/and noSetBindingcall site. The attribute never shipped (every tag predates #1108), so this takes away nothing that ever worked in a release. The limitation is documented indocs/aot-support.mdinstead.Package versions
Microsoft.WindowsAppSDK.WinUI2.6.6-experimental2.3.10-experimental; still absent from every stable release (checked through2.7.0, released 2026-11-17: not in its projection, its winmd, or thewinui3/release/2.7.0source) and stillFeature_ExperimentalApion microsoft-ui-xamlmainMicrosoft.WindowsAppSDK2.6.6-experimental2.6.6-experimentaland pinsRuntime [2.6.6-experimental]Both are public nuget.org packages, and the pairing satisfies the metapackage-nuspec rule in
Directory.Build.props(spec 063 §3). No package-reference workaround is needed — an earlier revision of this PR carried one, and it has been removed;Reactor.AppTests.Host.csprojis now untouched by this branch.Three incidental fixes this SDK requires:
CS8305silenced for the generatedXamlTypeInfo.g.csonly. The XAML compiler's generated file references the SDK's own experimental metadata providers (XamlControlsCharts/XamlControlsTabular), so every WinUI project emits it from code we do not own. It is an.editorconfigseverity scoped to**/XamlTypeInfo.g.cs, notWarningsNotAsErrors: CI's doc-snippet gate passes-p:WarningsNotAsErrors=NU1900on the command line, and a global property replaces the project value, which turned CS8305 back into an error there. CS8305 stays live for Reactor's own code (verified with a probe file namingDataTemplateElementFactory).REACTORGEN016downgraded to a suggestion intests/andsamples/. Fix generated-wrapper XAML metadata registration under NativeAOT #1583 made the wrapper generator pick a uniqueIXamlMetadataProviderfrom the wrapped control's assembly. On this channelMicrosoft.WinUIships three (the same experimental Charts and Tabular providers behind CS8305; stable 2.2.1 and 2.7.0 ship one), so every wrapper of a built-in WinUI control warns, and Release fails. The generator then falls back toTryRegisterControlAssembly, which is what every wrapper emitted before Fix generated-wrapper XAML metadata registration under NativeAOT #1583.main's Release build has noREACTORGEN016, so this hides nothing else. Verified: the AppTests host's Release build had 7 errors without it and 0 with it.IElementFactorycref inIItemsRepeaterFactorySource. This SDK addsMicrosoft.UI.Xaml.IElementFactoryalongsideMicrosoft.UI.Xaml.Controls.IElementFactory, making the bare cref ambiguous (CS0419) and failing the warnings-as-errors Release build. Verified still required — restoring the bare cref reproduces it.Why this still cannot merge
The API is public, but it is still
[feature(Feature_ExperimentalApi)], so consuming it pins the whole repo to the-experimentalchannel. To keep CI meaningful while this is a draft, the branch accepts that, and one change below is deliberately draft-only:2.6.6-experimental.WinAppSDKReferenceGuardTestsrequires that no literal pin sits below the central version. That includes 18 recipe files packed into the shipped NuGet agent kit (skills/recipes/,plugins/reactor/skills/reactor-recipes/references/),SKILL.md, the CLI scaffold, and samples. Shipping that would push an experimental SDK onto users, so these must move to the stable version at graduation. That is the main reason this stays a draft.CI on the experimental channel
The last head before these fixes failed 9 jobs. Each had a narrow cause, and none needed a workflow edit:
WarningsNotAsErrorsclobbered the project value.editorconfigscoped toXamlTypeInfo.g.cs2.6.6-experimentalwinui3/release/2.2.0andwinui3/release/2.5.4-experimental, and the tag compare is non-empty (300 files) as a positive control2.3.13-experimental,LocalSettingswrites the machine-local hive, so WindowsAppSDK#6559 is fixedbootstrap.ps1NU1107from the template's stable default0.0.8-alpha(#1465) thereactortemplates carry noMicrosoft.WindowsAppSDKreference, so the scaffold takes the SDK from the local Reactor package. The earlier--wasdk-versionworkaround was removed (the parameter no longer exists)LT_*,SlotReplace_*_ChildUnmountedOncePDM_WrapGrid_Reverse_AllSurvivorsKeepIdentityThe
.OnUnmountbug..OnUnmountactions were keyed by the control's managed CsWinRT wrapper, so a GC between mount and unmount silently dropped them. This is pre-existing (the same probe failed onmain), not an SDK regression. This branch originally carried a fix, but #1434 fixed it onmainindependently (with owner tracking and a GC regression test inSlotReplacementFixtures), so the rebase takesmain's version and this PR no longer touches the reconciler for it.Validation
2.6.6-experimental, rebased ontomainas6ba6a55a1(daily sync, Nov 21). WinUI and Runtime moved together per the metapackage nuspec, along with the 24 literal pins. The motion-parity guard is now verified tag-exact: the four motion sources have identical blob SHAs atwinui3/release/2.6.6-experimental(55b3fb8f0f) and2.6.5, and the2.5.4-experimental→2.6.6-experimentalcompare is 300 files as a positive control. Validated locally on 2.6.6:src/ReactorRelease 0 errors; SDK guard unit tests 106/106; selftestsTXB_6,TTV_65,KLR_73,LT_15,SlotReplace_228, plus main's newThemeRefStyle_111 (Fix ThemeRef PaneBackground, InteractionStates restore, author Style and key quoting on the Style path #1636) andThemeRefProbeProcessTests7 (Resolve ThemeRef through WinUI instead of reading theme dictionaries #1633), all green. CI: 46 pass / 0 fail / 3 skipped on the first run. (Nov 19: the first push failedBuild solutionand both AOT lanes withREACTORGEN016, fixed then, see above.) (Nov 17 needed one re-run:Packaged Selftests (1/2)failedAnimRemove_Modifier_OpacityIsImmediate, a check added by Fix .Animate() configuration comparison and removal ordering #1499 the day before, which passed in the AOT lane on the same SDK, 8/8 locally, and on re-run.) (Nov 12 needed one re-run of two known timing flakes:RapidClearWait_*in a coverage lane,AutoSuggestBoxCollectedStateTick_HeldOnlyByUnloadedinSelftests (2/2).) On Nov 11,Packaged Selftests (1/2)failedAutoSuggestBoxCollectedStateTick_CallbackAddedLate_TickDelivered. That check has now failed in CI only on the two experimental-SDK branches, so I measured it: it passes 25/25 on an idle machine. Under full CPU load it failed 1/20 on this branch, and also failed onmainwith the stable SDK (WinUI 2.2.1) in the same interleaved run. The WinUIAutoSuggestBoxsource differs between stable and experimental only by one accessor, and the 150 ms timer is unchanged. So it is an existing load-sensitive timing check, not an SDK regression.REACTOR_SELFTEST_SHARD=2/2 dotnet test tests/Reactor.SelfTests -p:Platform=x64): pre-fix, the new fixture failed 6/6 runs andSlotReplace_RegisteredHostReconcilesChild_Removed_ChildUnmountedOncereproduced the CI failure (text unmounted 0 times); with the fix, 3/3 green (969/970, 1 intentional skip). Shard 1 green (969/970).src/ReactorRelease build (split restore/build): 0 errors..OnUnmount(PerfDiffSkipPathTestsand related): 56/56. FullReactor.Testsearlier on this branch: green except the knownCompilationLoaderTests.Cold_load_under_500mstiming flake (passes 3/3 isolated).Before taking this out of draft
[feature(Feature_ExperimentalApi)]to stable, then move both versions onto the stable channel (keeping the metapackage-nuspec pairing rule)SKILL.md, CLI scaffold, samples, perf script) to that stable version[**/XamlTypeInfo.g.cs]CS8305 section and theREACTORGEN016section in.editorconfig; both exist only for the experimental channelIElementFactorycref disambiguation is still needed on the stable SDKRelated
microsoft-ui-xaml:DataTemplate_Partial.h, surface inmicrosoft.ui.xaml.controls.controls.idldocs/specs/proposals/winui3-integration.md. The themingXamlReader.LoadforStyle(§22/§23) is a separate gap and is untouched.{Binding}path alive on the stable SDK.