[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M69B8R3MR39KBJ6V4NXGEB2N":3,"skill-same:01M69B8R3MR39KBJ6V4NXGEB2N":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":47,"linkOnly":48,"markdownContent":49,"markdownBody":50,"frontMatter":51,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":58,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M69B8R3MR39KBJ6V4NXGEB2N","reactor-getting-started",null,"Reactor essentials in one place — React-to-Reactor mental model, minimal app shape, hooks, the most-used factories, the critical gotchas, and project setup. This is the only skill you need loaded for typical Reactor work; load topical skills (`reactor-async`, `reactor-design`, etc.) only when the task explicitly calls for them.","microsoft\u002Fmicrosoft-ui-reactor","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M69B6EF21X2GHARCXN2BH1K1",896,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor\u002Fblob\u002Fmain\u002Fplugins\u002Freactor\u002Fskills\u002Freactor-getting-started\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],"getting started","reactor getting started","when","task","load","minimal","calls","async","mental model","for","work","you","critical","only","hooks","project","model","app","react","design","2026-11-10 10:12:30",false,"---\nname: reactor-getting-started\ndescription: \"Reactor essentials in one place — React-to-Reactor mental model, minimal app shape, hooks, the most-used factories, the critical gotchas, and project setup. This is the only skill you need loaded for typical Reactor work; load topical skills (`reactor-async`, `reactor-design`, etc.) only when the task explicitly calls for them.\"\n---\n\n## Coming from React? Read this first.\n\n**Reactor concepts are React's, with one C# spelling.** If you know React, you already know how Reactor works — components render an element tree, hooks manage state and effects, lists need keys, lifting state up is the same. Trust your React intuition for *shape*; verify the *names* against the table below or `references\u002Freactor.api.txt`.\n\n| React | Reactor (C#) |\n|---|---|\n| `function App() { … }` | `class App : Component { override Element Render() { … } }` |\n| `useState(0)` | `var (count, setCount) = UseState(0);` |\n| `useReducer(reduce, init)` | `var (state, dispatch) = UseReducer\u003CTState,TAction>(reduce, init);` |\n| `useEffect(fn, [dep])` | `UseEffect(fn, dep);` |\n| `useMemo(() => v, [dep])` | `UseMemo(() => v, dep)` |\n| `useCallback(fn, [dep])` | `UseCallback(fn, dep)` |\n| `useRef(v)` | `UseRef(v)` |\n| callback ref \u002F `ref={node => …}` | `UseElementRef\u003CT>()` + `.Ref(r)` |\n| `useContext(Ctx)` | `UseContext(Ctx)` |\n| `\u003CProvider value={x}>{c}\u003C\u002FProvider>` | `c.Provide(Ctx, x)` |\n| `\u003Cdiv>` (linear layout) | `FlexColumn(...)` \u002F `FlexRow(...)` (CSS-flexbox semantics) |\n| `\u003Cdiv>` (shrink-wrap) | `VStack(...)` \u002F `HStack(...)` |\n| `\u003Cspan>text\u003C\u002Fspan>` | `TextBlock(\"text\")` |\n| `\u003Ch1>` \u002F `\u003Ch2>` \u002F small caption | `Heading(...)` \u002F `SubHeading(...)` \u002F `Caption(...)` |\n| `\u003Cbutton onClick={fn}>` | `Button(\"label\", fn)` |\n| `\u003Cinput value={v} onChange={e=>…}>` | `TextBox(v, setV)` |\n| `\u003Cselect>` | `ComboBox(items, index, setIndex)` |\n| `\u003Cinput type=\"checkbox\">` | `CheckBox(checked, setChecked)` |\n| `{cond && \u003CX\u002F>}` | `cond ? X() : null` (null children are filtered) |\n| `{a ? \u003CX\u002F> : \u003CY\u002F>}` | `a ? X() : Y()` |\n| `{items.map(i => \u003CCard key={i.id} … \u002F>)}` | `items.Select(i => Component\u003CCard,…>(…).WithKey(i.id)).ToArray()` |\n| `\u003CCard {...props} \u002F>` | `Component\u003CCard, CardProps>(new CardProps(...))` |\n| `key={i.id}` | `.WithKey(i.id)` |\n| `className=\"...\"` (style) | `.Background(...)`, `.Padding(...)`, `.Margin(...)`, etc. |\n| `style={{margin: 10}}` | `.Margin(10)` |\n| `display: flex; flex: 1` | `FlexRow(...)` \u002F `.Flex(grow: 1, basis: 0)` |\n| `gap: 8` | `VStack(8, …)`, `FlexRow(...) with { ColumnGap = 8 }` (FlexColumn → `RowGap`) |\n| React Query `useQuery` \u002F `useMutation` | `UseResource` \u002F `UseMutation` (see `reactor-async`) |\n| JSX | C# method calls + `using static Microsoft.UI.Reactor.Factories` |\n\n**One important difference:** in Reactor, `UseState` with a `List\u003CT>` won't re-render on `.Add()` — same reference. Use `UseReducer` for lists (just like `useReducer` is preferred in React for complex state).\n\n\n> **Controlled prop note:** the factories shown here still take plain values\n> (`TextBox(text, setText)`, `Slider(value, ...)`) and wrap them for you.\n> Element-record properties behind those factories use `Optional\u003CT>` so\n> `Optional\u003CT>.Unset` can mean \"the control owns this value\". See\n> [`migration\u002F050-optional-t.md`](..\u002F..\u002F..\u002F..\u002Fdocs\u002Fguide\u002Fmigration\u002F050-optional-t.md).\n\n## Starting a new app\n\n`dotnet new reactor -n \u003CName>` scaffolds the canonical shape: `App.cs` (entry point + initial component, with the `using` block at the top) plus `\u003CName>.csproj`. Richer shells: `reactor-mvu`, `reactor-navview`, `reactor-tabview`. See the anti-probe + `mur check` notes under \"Use a `.csproj` …\" below for what comes out of the scaffold.\n\nFor a single-file `dotnet run App.cs` demo (no `.csproj`), `dotnet new reactor-singlefile -n \u003CName>` scaffolds `\u003CName>\u002F\u003CName>.cs` with the file-level `#:package` \u002F `#:property` header already in place. Keep all the code in that file, because a file-based app compiles only that one file. Check it with `mur check \u003CName>.cs` from its folder; a bare `mur check` builds the current directory, which needs a project file. To add the header to an existing file instead, see `reactor-build-and-check`'s single-file-scripts section.\n\nIf `dotnet new` rejects `--packaging` or can't find `reactor-singlefile`, the installed pack predates them; `winapp new --list --template-version latest` updates it.\n\n## Use a `.csproj` when you need …\n\n… multiple files, **analyzers** (single-file `.cs` builds don't load them), or shared project references. `dotnet new reactor` scaffolds the canonical csproj — you don't need to author one from scratch.\n\n`UseWinUI` MUST be `true`. **No XAML files of any kind.**\n\n**Don't change the packaging mode of a project you didn't scaffold — keep whatever the scaffold\nproduced.** Reactor works in both shapes:\n\n- **Unpackaged** — `\u003CWindowsPackageType>None\u003C\u002FWindowsPackageType>`, no `Package.appxmanifest`.\n  `None` wins over `EnableMsixTooling`, so a project carrying both still builds unpackaged. Runs\n  from any folder, no MSIX registration. Scaffold it with `dotnet new reactor --packaging Unpackaged`\n  (the other project templates take `--packaging` too).\n- **Packaged** — has a `Package.appxmanifest`. Either omit `WindowsPackageType` entirely (the\n  default produces a packaged app) or set it to `MSIX`; pair it with `EnableMsixTooling=true` for\n  the single-project MSIX tooling. Launches with package identity, which is what identity-gated\n  APIs require. This is what the `dotnet new reactor` family produces by default.\n\nNeither is \"the\" Reactor shape, and neither is signalled by one property alone. **If a project has a\n`Package.appxmanifest`, it is packaged on purpose — adding\n`\u003CWindowsPackageType>None\u003C\u002FWindowsPackageType>` to it silently strips its identity, and the build\nstill succeeds, so nothing surfaces the mistake.** Switch modes only when the user asks, and switch\nthe whole property *set*, not a single flag — the `packaging` guide has both shapes in full,\nincluding the explicit-`MSIX` form.\n\n**After `dotnet new reactor -n \u003CName>`, the source you edit is `App.cs` (entry point + initial component) next to `\u003CName>.csproj`.** The templates also scaffold build and packaging inputs — `app.manifest`, `Assets\u002F`, `Properties\u002FlaunchSettings.json`, `Properties\u002FPublishProfiles\u002F`, `.vscode\u002F`, and `Package.appxmanifest` when packaged; those are not source — leave them alone. The scaffold's `AGENTS.md` holds WinApp CLI workflow notes (`winapp ui …`, `winapp find-ui --source reactor`); it complements this skill. There is no `Program.cs` and no `GlobalUsings.cs` — modify `App.cs` in place. `App.cs` has its own `using` directives at the top — see the *Required imports* section below — and that is where you add new namespaces (e.g. `using System.Linq;` when you reach for `.Select(...)`). Some templates enable implicit usings, so a namespace may already be in scope. Don't probe the `.csproj` after scaffolding unless you're adding a `PackageReference` or changing a property — `Restore succeeded.` in the scaffold stdout is the only confirmation you need.\n\n**Scaffolded apps are packaged by default, so `dotnet run` launches them with MSIX package identity** — the F5 equivalent. That needs **Developer Mode on** (Settings → System → For developers) to register the loose-layout package, and a concrete architecture (the template declares `x86;x64;ARM64`; AnyCPU is rejected). A `--packaging Unpackaged` scaffold runs as a plain `.exe` with no package registration, so it doesn't need Developer Mode.\n\n**The scaffolded csproj ships a Debug-only ItemGroup that adds `Microsoft.UI.Reactor.Devtools` + `Reactor.DevtoolsSupport=true`.** That makes devtools available without turning them on. For the in-app dev menu, run `dotnet run -- --devtools app` and make sure the app renders `DevtoolsMenu(...)`, e.g. in its title bar — the flag alone draws nothing. `dotnet run` hands everything after `--` to the app, and a packaged scaffold still receives it when it launches with package identity. Keep the `app`: a bare `--devtools` is read as `--devtools run`, the heavier session behind `mur devtools` that also starts an MCP endpoint. `Properties\u002FlaunchSettings.json` depends on the packaging. A packaged scaffold lists a **Package** profile first, Visual Studio's F5 default, and an **Unpackaged** profile second. `dotnet run` can't apply MSIX profiles, so it picks **Unpackaged**, but WinApp still launches the app with package identity. WinApp also supplies its own run arguments, so `dotnet run` ignores profile arguments there; pass `-- --devtools app` yourself. In Visual Studio, keep **Package**: choosing **Unpackaged** there starts the exe without identity, and it fails at startup with `REGDB_E_CLASSNOTREG`. A `--packaging Unpackaged` scaffold has an **Unpackaged** profile plus an **Unpackaged, Devtools** profile that passes `--devtools app`. Release builds drop the devtools package and host-config switch so trim \u002F AOT analyzers stay quiet — see the `packaging` guide for the full rationale before flipping either knob.\n\n**Verify your edits with `mur check`** before declaring done. From the project directory: `mur check` (no arguments) runs `dotnet build` and emits one compressed line per diagnostic with a `→ try:` suggestion when the engine recognizes the mistake; `mur check --final` is the explicit \"I am done iterating\" sweep that emits the full diagnostic set including suppressed iteration-mode warnings. For anything more involved than the build\u002Ffix loop — strict-mode failures, custom diagnostic gating, MSBuild passthrough flags — load the `reactor-build-and-check` skill.\n\n## Required imports\n\n```csharp\nusing System;\nusing Microsoft.UI.Reactor;\nusing Microsoft.UI.Reactor.Core;\nusing Microsoft.UI.Reactor.Layout;   \u002F\u002F FlexDirection, FlexJustify, FlexAlign\nusing Microsoft.UI.Xaml;             \u002F\u002F Thickness, HorizontalAlignment, VerticalAlignment\nusing Microsoft.UI.Xaml.Controls;    \u002F\u002F Orientation, InfoBarSeverity, etc.\nusing static Microsoft.UI.Reactor.Factories;\n```\n\n## Components\n\n```csharp\n\u002F\u002F Class component (primary)\nclass Counter : Component\n{\n    public override Element Render()\n    {\n        var (count, setCount) = UseState(0);\n        return VStack(TextBlock($\"Count: {count}\"),\n                      Button(\"+1\", () => setCount(count + 1)));\n    }\n}\n\n\u002F\u002F Function component (inline, small reusable pieces)\nvar toggle = Memo(ctx =>\n{\n    var (on, setOn) = ctx.UseState(false);\n    return ToggleSwitch(on, setOn);\n});\n\n\u002F\u002F Typed props — use records for free structural equality\nrecord UserCardProps(string Name, string Role);\nclass UserCard : Component\u003CUserCardProps>\n{\n    public override Element Render() =>\n        VStack(TextBlock(Props.Name), Caption(Props.Role));\n}\nComponent\u003CUserCard, UserCardProps>(new UserCardProps(\"Alice\", \"Admin\"))\n\n\u002F\u002F Memoized function component\nMemo(ctx => TextBlock(\"Stable\"))               \u002F\u002F render once + own state\nMemo(ctx => TextBlock($\"Hi, {name}\"), name)    \u002F\u002F re-render when deps change\n```\n\n`Component` skips parent-triggered re-renders by default. `Component\u003CTProps>` skips when `Equals(oldProps, newProps)`.\n\n**App entry point.** `ReactorApp.Run\u003CMyRoot>(\"Title\", width: W, height: H)` against a component class (the scaffolded form). `width`\u002F`height` are optional DIPs — omit them to let the OS choose the initial window size. For a tiny demo without a class, the inline form: `ReactorApp.Run(\"Title\", ctx => { var (m, setM) = ctx.UseState(\"hi\"); return TextBlock(m); })`.\n\n## Hooks\n\n**Rules:** same order every render (no hooks in `if`\u002F`for`), only from `Render()` or function-component body.\n\n| Hook | Returns | Use for |\n|---|---|---|\n| `UseState\u003CT>(initial)` | `(T, Action\u003CT>)` | Primary state |\n| `UseReducer\u003CT>(initial)` | `(T, Action\u003CFunc\u003CT,T>>)` | State derived from previous (lists) |\n| `UseReducer\u003CTState,TAction>(reduce, initial)` | `(TState, Action\u003CTAction>)` | Action-style reducer |\n| `UseEffect(action, deps)` | — | Side effects + cleanup |\n| `UseMemo\u003CT>(factory, deps)` | `T` | Memoized computation |\n| `UseCallback(action, deps)` | `Action` | Stable callback reference |\n| `UseRef\u003CT>(initial)` | `Ref\u003CT>` | Mutable ref across renders (access via `.Current`) |\n| `UseObservable\u003CT>(source)` | `T` | Track `INotifyPropertyChanged` |\n| `UseExternalStore\u003CTSnapshot>(subscribe, getSnapshot)` | `TSnapshot` | Subscribe to an external store (stable `subscribe`, cached snapshot) |\n| `UseCollection\u003CT>(coll)` | `IReadOnlyList\u003CT>` | Track `ObservableCollection` |\n| `UseContext\u003CT>(ctx)` | `T` | Read tree-scoped ambient state |\n| `UsePersisted\u003CT>(key, initial)` | `(T, Action\u003CT>)` | State that survives unmount |\n| `UseResource\u003CT>` \u002F `UseInfiniteResource` \u002F `UseMutation` | (see `reactor-async`) | Async data |\n| `UseValidationContext()` | `ValidationContext` | (see `reactor-forms`) |\n| `UseNavigation\u003CTRoute>(initial)` | `NavigationHandle\u003CTRoute>` | (see `reactor-navigation`) |\n\n### UseState\n\n\u003C!-- index:use-state -->\n`UseState\u003CT>(initial)` returns `(value, setValue)`. Calling the setter with a\nvalue that differs from the current one schedules a re-render; the new value is\nvisible on the *next* render, not on the line after the call.\n\n```csharp\nvar (count, setCount) = UseState(0);\n\nreturn VStack(8,\n    TextBlock($\"Count: {count}\"),\n    Button(\"Increment\", () => setCount(count + 1)));\n```\n\nTwo rules decide whether `UseState` is the right hook:\n\n- **Hook order is constant.** Never call a hook inside `if`, `for`, or a\n  nested lambda — call them all unconditionally and use the result\n  conditionally. `REACTOR_HOOKS_001` enforces this.\n- **Reference types need a new instance.** `UseState(new List\u003CT>())` followed\n  by `list.Add(item)` will not re-render: the reference is unchanged, so the\n  setter never sees a difference. Reach for `UseReducer` instead.\n\nPass `threadSafe: true` when the setter is called from a background thread.\n\u003C!-- \u002Findex:use-state -->\n\n### UseReducer\n\n\u003C!-- index:use-reducer -->\n`UseReducer` is the hook for state derived from the previous value — above all\ncollections, where `UseState` silently fails to re-render because the mutated\nlist is the same reference.\n\n```csharp\nvar (items, updateItems) = UseReducer(new List\u003Cstring>());\n\nupdateItems(list => [.. list, \"New item\"]);   \u002F\u002F always a NEW list\n```\n\nThe updater receives the current value and returns the next one, so it is\ncorrect even when several updates are queued in one tick — unlike\n`setItems(items.Concat(...))`, which reads a captured `items` that may\nalready be stale.\n\nThe two-type-parameter overload takes an explicit reducer for action-style\nstate machines:\n\n```csharp\nvar (state, dispatch) = UseReducer\u003CBoardState, BoardAction>(Board.Reduce, BoardState.Initial);\n```\n\u003C!-- \u002Findex:use-reducer -->\n\n### UseEffect\n\n\u003C!-- index:use-effect -->\n`UseEffect(action, deps)` runs *after* the render commits. Return an `Action`\nto register cleanup — it runs before the next execution of the effect and once\nmore on unmount, which is what makes timers, subscriptions, and event handlers\nsafe to own from a component.\n\n```csharp\nvar (ticks, bumpTicks) = UseReducer(0);\n\nUseEffect(() =>\n{\n    var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };\n    timer.Tick += (_, _) => bumpTicks(t => t + 1);\n    timer.Start();\n    return () => timer.Stop();     \u002F\u002F cleanup on dep change and on unmount\n}, Array.Empty\u003Cobject>());\n```\n\nDependency rules:\n\n- Deps are a `params` argument, so `UseEffect(fn)` and\n  `UseEffect(fn, Array.Empty\u003Cobject>())` are the same call: empty deps compare\n  equal on every later render, so the effect runs **once, on mount**.\n- One or more deps → re-runs whenever any of them compares unequal.\n- **A freshly allocated object or lambda is never equal to the previous one**, so\n  it defeats the comparison and the effect re-runs every commit. (A type with\n  value-based `Equals`, such as a `record`, is the exception.)\n- **A lone reference-type array is the other exception** — it is treated as a\n  dependency *list* and compared element-wise, so `new[] { a, b }` re-allocated\n  each render with equal contents is stable.\n- **Tuple deps are rejected by the analyzer, not by the runtime.** A `ValueTuple`\n  of value types compares by value, so `(x, y)` would work — but\n  `REACTOR_HOOKS_004` classifies every tuple expression as an unstable dep and\n  fails the build. Use a string key such as `$\"{x}|{y}\"`, or separate deps:\n  `UseEffect(fn, x, y)`.\n\u003C!-- \u002Findex:use-effect -->\n\n### UseMemo and UseCallback\n\n\u003C!-- index:use-memo -->\n`UseMemo\u003CT>(factory, deps)` caches the result of an expensive computation and\nrecomputes it only when a dependency changes. `UseCallback(action, deps)` does\nthe same for a delegate, so a child that compares handlers by reference is not\nre-rendered by a freshly allocated lambda.\n\n```csharp\nvar sorted = UseMemo(() => items.OrderBy(i => i.Name).ToList(), items);\nvar onReset = UseCallback(() => setQuery(\"\"), Array.Empty\u003Cobject>());\n```\n\nBoth obey the same dependency rule as `UseEffect`: a fresh **object** or\n**lambda** allocated during render is never equal to the previous one and defeats\nthe cache entirely (a `record` is the exception, and a lone reference-type array\nis treated as a dependency *list* and compared element-wise, so equal contents\nstay stable). A tuple expression — though value-equal at runtime — is rejected\noutright by `REACTOR_HOOKS_004`. Memoize the computation, not the render —\n`UseMemo` is for work that is measurably expensive, not for every projection.\n\u003C!-- \u002Findex:use-memo -->\n\n### UseRef\n\n\u003C!-- index:use-ref -->\n`UseRef\u003CT>(initial)` returns a `Ref\u003CT>` — a mutable box that survives re-renders\nand, unlike `UseState`, **never triggers one**. Use it for values a render does\nnot read: a timer handle, a subscription token, a \"did I already do this\" flag,\nor a high-frequency value written during a gesture.\n\n```csharp\nvar timerRef = UseRef\u003CDispatcherTimer?>(null);\n\ntimerRef.Current = new DispatcherTimer();   \u002F\u002F .Current is the property — NOT .Value\ntimerRef.Current.Start();\n```\n\n`Ref\u003CT>` is Reactor's own box and exposes `.Current`. Do not confuse it with\n`ElementRef` \u002F `UseElementRef\u003CT>`, which points at a realized WinUI element and\nis populated by the reconciler rather than by you.\n\u003C!-- \u002Findex:use-ref -->\n\n### UseContext\n\n\u003C!-- index:context -->\nA `Context\u003CT>` passes ambient state down the tree without threading it through\nevery intermediate component. Declare the context once as a static, provide a\nvalue on an ancestor with `.Provide(...)`, and read it with `UseContext`.\n\n```csharp\npublic static readonly Context\u003Cstring> ThemeCtx = new(\"light\");\n\n\u002F\u002F Provide — every descendant sees \"dark\"\nVStack(8, Component\u003CToolbar>(), Component\u003CBody>()).Provide(ThemeCtx, \"dark\")\n\n\u002F\u002F Consume, anywhere below\nvar theme = UseContext(ThemeCtx);\n```\n\nThe value passed to `new Context\u003CT>(...)` is the default a consumer reads when\nno ancestor provides one, so `UseContext` never returns an unexpected `null`.\nProviding a new value re-renders the consumers below it, not the whole tree.\n\u003C!-- \u002Findex:context -->\n\n## Common factories — the 90% cases\n\nThe full catalog (every factory, modifier, enum) is in `references\u002Freactor.api.txt`. The signatures below cover most apps; consult the index when you need a control not listed here.\n\n```csharp\n\u002F\u002F Layout\nVStack(spacing, children...)                  HStack(spacing, children...)\nFlexColumn(children...)                       FlexRow(children...)\n\u002F\u002F Prefer FlexRow\u002FFlexColumn for linear layout — CSS Flexbox semantics\n\u002F\u002F (grow\u002Fshrink\u002Fgap\u002Fwrap, justify-content, align-items). VStack\u002FHStack\n\u002F\u002F remain for StackPanel's shrink-wrap behavior.\nBorder(child).CornerRadius(8).Background(Theme.CardBackground).Padding(16)\nScrollView(VStack(...))      \u002F\u002F modern (default); ScrollViewer(...) is the classic Control\nGrid(columns: [GridSize.Star(), GridSize.Px(200)],\n     rows:    [GridSize.Auto,   GridSize.Star()],\n    TextBlock(\"Header\").Grid(row: 0, column: 0, columnSpan: 2),\n    ListView(items, ...).Grid(row: 1, column: 0),\n    Sidebar().Grid(row: 1, column: 1))\nTitleBar(\"App\") with { Subtitle = \"Home\", Content = ..., RightHeader = ... }\nContentDialog(string title, Element content, string primaryButtonText = \"OK\")\nFlyout(Element target, Element content)\nNavigationView(items, content) with { SelectedTag = \"home\", IsPaneOpen = true }\n\n\u002F\u002F Text\nTextBlock(\"hi\")        Heading(\"Title\")        SubHeading(\"Section\")        Caption(\"note\")\n\u002F\u002F Strings auto-convert to TextBlockElement: VStack(\"A\", \"B\") works.\n\n\u002F\u002F Controls\nButton(\"Click\", () => ...)                                    \u002F\u002F positional: (label, onClick)\nButton(\"Save\", onClick: handler).Background(Theme.Accent)     \u002F\u002F named-arg form before modifiers\n\u002F\u002F `onClick` is a Button ctor parameter — NOT a chained `.OnClick(...)` \u002F\n\u002F\u002F `.OnTapped(...)`. `.OnTapped` is a gesture event with different input\n\u002F\u002F semantics (long-press, touch, pen) and is the wrong fix for click intent.\nTextBox(value, setValue, placeholderText: \"...\")\nCheckBox(isChecked, onChanged: setChecked, label: \"label\")\nToggleSwitch(on, setOn)\nSlider(v, 0, 100, setV)\nComboBox(items, selectedIndex, setIndex)\nProgressIndeterminate()                  ProgressRing()\nInfoBar(\"Title\", \"message\").Severity(InfoBarSeverity.Error)\n\n\u002F\u002F Lists \u002F templated\nListView\u003CT>(items, keySelector, viewBuilder)\nGridView\u003CT>(items, keySelector, viewBuilder)\nDataGrid\u003CT>(source, columns, ...)        \u002F\u002F see reactor.api.txt for full signature\n\n\u002F\u002F Conditional \u002F iteration\nisLoggedIn ? TextBlock($\"Hi, {name}\") : Button(\"Log in\", onLogin)\nVStack(TextBlock(\"always\"), showExtra ? TextBlock(\"maybe\") : null)   \u002F\u002F null filtered\nWhen(items.Any(), () => TextBlock($\"{items.Count} items\"))\nIf(isError, () => InfoBar(\"Error\", msg).Severity(InfoBarSeverity.Error),\n            () => TextBlock(\"OK\"))\nstatus switch {\n    Status.Loading => ProgressIndeterminate(),\n    Status.Error   => TextBlock(\"Oops\"),\n    Status.Success => Component\u003CSuccessView>(),\n    _ => Empty()\n}\nForEach(items, item => TextBlock(item.Name))\nitems.Select(i => Component\u003CCard, CardProps>(new CardProps(i)).WithKey(i.Id)).ToArray()\n\n\u002F\u002F Common modifiers\n.Margin(10)            .Margin(left: 8, top: 4, right: 8, bottom: 4)\n.Padding(16)           .Background(Theme.CardBackground)\n.Foreground(Theme.PrimaryText)\n.CornerRadius(8)       .WithBorder(Theme.CardStroke, 1)\n.Flex(grow: 1, basis: 0)        \u002F\u002F CSS `flex: 1` equivalent\n.WithKey(\"id\")                  \u002F\u002F dynamic list items — see gotcha #6\n.OnTapped((s, e) => ...)        \u002F\u002F tap on non-Button surfaces — Border, Image, ScrollView, …\n                                \u002F\u002F (Button click → ctor arg, see Controls section)\n                                \u002F\u002F ⚠️ For UIA\u002Fautomation: always pair with .AutomationName(\"...\")\n.AutomationName(\"Submit\")       \u002F\u002F a11y — sets AutomationProperties.Name\n.Ref(targetRef)                 \u002F\u002F bind an ElementRef\u003CT>; Compose FocusRequester \u002F React callback-ref shape\n.Target(targetRef)              \u002F\u002F reference prop, e.g. TeachingTip.Target; also .LabeledBy\u002F.XYFocusRight\n.Set(native => native.MaxWidth = 400)   \u002F\u002F native escape hatch (lambda receives the WinUI control)\n```\n\n## Theme tokens (always)\n\nUse `Theme.*` for all themed colors — never hardcoded hex on themed surfaces. The full token list with WinUI keys is in the `reactor-design` skill.\n\n> ⚠️ **`Theme.Error`, `Theme.Success`, `Theme.Warning`, `Theme.ErrorText` do NOT exist.**\n> Use `Theme.SystemCritical` (red\u002Ferror), `Theme.SystemSuccess` (green), `Theme.SystemCaution` (yellow).\n\n```csharp\nTextBlock(\"Hi\").Foreground(Theme.PrimaryText)\nBorder(child).Background(Theme.CardBackground).WithBorder(Theme.CardStroke, 1)\nButton(\"Action\").Background(Theme.Accent)\nTextBlock(\"Error!\").Foreground(Theme.SystemCritical)       \u002F\u002F NOT Theme.Error\nTextBlock(\"Saved\").Foreground(Theme.SystemSuccess)         \u002F\u002F NOT Theme.Success\n```\n\n## Critical gotchas\n\n1. **Hook order is constant.** No hooks inside `if`\u002F`for`. Call them all unconditionally; conditionally use the result.\n2. **Type-specific sugar before generic modifiers.**\n   `TextBlock(\"Hi\").Bold().Margin(10)` ✓ — `.Bold()` needs `TextBlockElement`.\n   `TextBlock(\"Hi\").Margin(10).Bold()` ✗ — `.Margin()` returns `Element`.\n3. **List mutations need `UseReducer`.** `UseState(new List\u003CT>())` + `list.Add()` won't re-render — same reference. Use `UseReducer(list => [.. list, item])`.\n4. **Null children are filtered.** `VStack(a, condition ? b : null, c)` is safe.\n5. **Records with `with` for init-only properties.** `NavigationView(items, content) with { SelectedTag = \"home\", IsPaneOpen = true }`.\n6. **`.WithKey(\"id\")` on dynamic list items.** Without keys, the reconciler matches by position and re-mounts everything on insert\u002Freorder — losing focus, animation state, ElementRef identity. The `REACTOR_DSL_001` analyzer catches this in `.csproj` builds.\n7. **Memoize expensive computations.** `UseMemo(() => items.OrderBy(...).ToList(), items)`.\n8. **`.Flex(grow: 1)` is `flex-grow`, not the CSS `flex: 1` shorthand.** Default basis is `auto` (content size), so a growing child with large intrinsic content overflows the container. Pass `.Flex(grow: 1, basis: 0)` (matches CSS `flex: 1`) or add `.Flex(shrink: 0)` to each fixed-size sibling.\n9. **Don't pass freshly-allocated objects\u002Farrays\u002Flambdas as hook deps.** They compare unequal every render → hook never hits its stable path. The `REACTOR_HOOKS_004` analyzer catches this. **Tuples are also rejected** — not because `(x, y)` compares unequal (a `ValueTuple` of value types is value-equal), but because the analyzer classifies every tuple expression as an unstable dep. Instead, use a string key: `$\"{x}|{y}\"`, or pass individual values as separate deps: `UseEffect(fn, x, y)`.\n10. **`UseResource` is reads-only.** Never call `Post*`\u002F`Create*`\u002F`Delete*`\u002F`Save*` from a `UseResource` fetcher — it can re-run on deps change, retry, and focus revalidation. Use `UseMutation` for writes.\n\n### Element refs and reference props\n\nUse `UseElementRef\u003CT>()` when one element needs to point at another real\nWinUI element. Attach the cell with `.Ref(...)`, then pass it to a\nreference prop such as `TeachingTip.Target`, `.LabeledBy(...)`, or\n`.XYFocusRight(...)`. This is Reactor's callback-ref \u002F Compose\n`FocusRequester` shape: the graph updates when the target mounts late,\nunmounts, or is recreated.\n\n```csharp\nvar target = this.UseElementRef\u003CFrameworkElement>();\n\nreturn HStack(\n    Button(\"Show tip\", () => setOpen(true)).Ref(target),\n    TeachingTip(\"Hint\", target: target) with { IsOpen = open });\n```\n\nDo **not** set relationship properties by reading `target.Current` in a\nhandler; use the reference prop so Reactor can clear and re-resolve it.\n\n## Common patterns (paste-ready)\n\nThese cover the bulk of \"stateful app with lists, dialogs, and per-row actions\" — copy and adapt rather than re-deriving from the api index.\n\n### Drag and drop (typed payload between two lists)\n\n```csharp\nusing Microsoft.UI.Reactor.Input;   \u002F\u002F DragOperations, DragData\n\nsealed record Item(string Id, string Title);\n\nElement RenderList(string title,\n                   IReadOnlyList\u003CItem> items,\n                   Action\u003CIReadOnlyList\u003CItem>> setThis)\n{\n    var children = new List\u003CElement> { TextBlock(title).SemiBold() };\n\n    foreach (var item in items)\n    {\n        var captured = item;                                         \u002F\u002F capture for the lambda\n        children.Add(\n            Border(TextBlock(captured.Title))\n                .Background(Theme.CardBackground).CornerRadius(6).Padding(10)\n                .OnDragStart\u003CBorderElement, Item>(\n                    getPayload: () => captured,\n                    allowedOperations: DragOperations.Move,\n                    onEnd: ctx =>\n                    {\n                        \u002F\u002F Move-on-confirmation: only remove after a confirmed Move\n                        \u002F\u002F (not on cancel or Copy). Avoids the source losing data\n                        \u002F\u002F if the drop target rejects.\n                        if (!ctx.WasCancelled && ctx.CompletedOperation == DragOperations.Move)\n                            setThis(items.Where(i => i.Id != captured.Id).ToList());\n                    })\n        );\n    }\n\n    return VStack(6, children.ToArray())\n        .OnDrop\u003CStackElement, Item>(\n            onDrop: dropped =>\n            {\n                if (!items.Any(i => i.Id == dropped.Id))\n                    setThis(items.Append(dropped).ToList());\n            },\n            acceptedOps: DragOperations.Move);\n}\n```\n\nFor cross-process text drag (drop into Notepad\u002FWord): use `.OnDragStart\u003CBorderElement>(() => new DragData().WithText(\"...\"))` and `.OnDrop\u003CBorderElement>(args => args.Data.TryGetText(out var t))`.\n\n### ContentDialog (modal — confirm, edit, alert)\n\n`ContentDialog` is a render-tree element with `IsOpen`\u002F`OnClosed` driven by component state — same pattern as React. Don't try to imperatively `.ShowAsync()`; let the reconciler manage it.\n\n```csharp\nvar (showConfirm, setShowConfirm) = UseState(false);\nvar (lastResult, setLastResult) = UseState(\"(none)\");\n\nVStack(8,\n    Button(\"Delete item\", () => setShowConfirm(true)),\n    TextBlock($\"Last result: {lastResult}\").Foreground(Theme.SecondaryText),\n\n    ContentDialog(\"Confirm delete\",\n                  TextBlock(\"Are you sure? This cannot be undone.\"),\n                  primaryButtonText: \"Delete\") with\n    {\n        IsOpen = showConfirm,\n        SecondaryButtonText = \"Cancel\",\n        OnClosed = result =>\n        {\n            setLastResult(result.ToString());\n            setShowConfirm(false);\n        },\n    }\n)\n```\n\nFor an \"edit existing item\" dialog: lift the item being edited into state (`UseState\u003CItem?>(null)`); when non-null, render the dialog with `IsOpen = editing != null`; in `OnClosed` either commit the edit and clear, or just clear.\n\n### Flyout \u002F context menu (right-click, dropdown menu)\n\n```csharp\n\u002F\u002F Right-click context menu on any element\nBorder(TextBlock(\"Right-click me\"))\n    .Padding(12).Background(Theme.SubtleFill).CornerRadius(6)\n    .WithContextFlyout(MenuItems(\n        MenuItem(\"Edit\",      () => beginEdit(item)),\n        MenuItem(\"Duplicate\", () => duplicate(item)),\n        MenuSeparator(),\n        MenuItem(\"Delete\",    () => delete(item))\n    ))\n\n\u002F\u002F Dropdown button with a menu\nDropDownButton(\"Sort\", flyout: MenuItems(\n    MenuItem(\"By name\", () => setSort(Sort.Name)),\n    MenuItem(\"By date\", () => setSort(Sort.Date)),\n    MenuSeparator(),\n    MenuItem(\"Reverse\", () => setSort(s => s.Reversed()))\n))\n\n\u002F\u002F Click flyout with custom content (vs. menu items)\nButton(\"Open flyout\", null).WithFlyout(ContentFlyout(\n    VStack(8,\n        TextBlock(\"Custom content here\").SemiBold(),\n        Slider(value, 0, 100, setValue)),\n    placement: Microsoft.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.Bottom\n))\n```\n\n### Context (dispatch \u002F theme passed without prop drilling)\n\nWhen many descendants need `dispatch(action)` or a theme value, define `Context\u003CT>` once and `.Provide(...)` from a parent. Same shape as React's `createContext` + `useContext`.\n\n```csharp\n\u002F\u002F At module\u002Fclass scope\nsealed record AppAction(string Name);\nstatic readonly Context\u003CAction\u003CAppAction>> DispatchCtx = new(_ => { });\n\n\u002F\u002F At the root\nclass App : Component\n{\n    public override Element Render()\n    {\n        var (state, dispatch) = UseReducer\u003CAppState, AppAction>(App.Reduce, AppState.Initial);\n\n        return VStack(\n            Heading(\"My app\"),\n            Component\u003CChildView>()\n        ).Provide(DispatchCtx, dispatch);     \u002F\u002F descendants can read this\n    }\n}\n\n\u002F\u002F Anywhere in the subtree\nclass ChildView : Component\n{\n    public override Element Render()\n    {\n        var dispatch = UseContext(DispatchCtx);\n        return Button(\"Do thing\", () => dispatch(new AppAction(\"ThingClicked\")));\n    }\n}\n```\n\nNested `.Provide()` overrides the outer for its subtree only. If no provider is present, `UseContext` returns the `Context\u003CT>` default.\n\n## Bootstrap\n\n`mur pack-local` (selfhost) and `nuget.config` (consumer outside the source clone) — see the top-level `SKILL.md`'s \"Which mode are you in?\" section. If selfhost restore fails with \"package Microsoft.UI.Reactor 0.0.0-local was not found\", run `mur pack-local`.\n\n> ⚠️ **Platform flag required when working *inside this repo* (selfhost)**: always build samples \u002F in-repo projects with an explicit platform: `dotnet build -p:Platform=x64` (or `ARM64`). Omitting `-p:Platform=...` causes `WindowsAppSDKSelfContained` errors. This applies to `dotnet build`, `dotnet run`, and `mur check` invocations alike.\n>\n> The `dotnet new reactor` template auto-resolves `RuntimeIdentifier` from the host SDK when `Platform`\u002F`RuntimeIdentifier` aren't explicit, so consumer projects scaffolded outside the repo build with bare `dotnet build` \u002F F5 — the rule above only applies in the selfhost tree.\n\n## Where the skill content comes from (and the api index)\n\nYou're reading this through the **`reactor` plugin** — the most efficient channel. The plugin SDK preloads `reactor-getting-started`; topical skills (`reactor-async`, `reactor-design`, `reactor-forms`, `reactor-navigation`, `reactor-input`, `reactor-recipes`, `reactor-wrapping` for turning any WinUI, vendor, or custom control into a declarative element via the `[GenerateReactorWrapper]` source generator, `reactor-advanced` for Win2D canvases via the optional `Microsoft.UI.Reactor.Advanced` package, etc.) load only when the task explicitly needs them.\n\nFull API index (every factory, modifier, hook, theme token, with parameter lists): `references\u002Freactor.api.txt` inside the `reactor-dsl` skill (also bundled into the Microsoft.UI.Reactor nupkg's `agentkit\u002F` tree if you need to find it from a consumer).\n\n**Read the api index once** when you need to confirm an unusual signature — it's ~12K tokens, but cheaper than the equivalent number of grep+read cycles. Don't re-read pages of it; cache what you need in your working memory.\n\n## Build output\n\n`dotnet run` exits with code 1 on build failure. **Always read the output** — don't assume success. After non-trivial edits, run `mur check \u003Cpath>` for one-line diagnostics with skill-file pointers (see `reactor-build-and-check`).\n\n> Remember: always pass `-p:Platform=x64` (or `ARM64`). Without it, the first build always fails.\n","## Coming from React? Read this first.\n\n**Reactor concepts are React's, with one C# spelling.** If you know React, you already know how Reactor works — components render an element tree, hooks manage state and effects, lists need keys, lifting state up is the same. Trust your React intuition for *shape*; verify the *names* against the table below or `references\u002Freactor.api.txt`.\n\n| React | Reactor (C#) |\n|---|---|\n| `function App() { … }` | `class App : Component { override Element Render() { … } }` |\n| `useState(0)` | `var (count, setCount) = UseState(0);` |\n| `useReducer(reduce, init)` | `var (state, dispatch) = UseReducer\u003CTState,TAction>(reduce, init);` |\n| `useEffect(fn, [dep])` | `UseEffect(fn, dep);` |\n| `useMemo(() => v, [dep])` | `UseMemo(() => v, dep)` |\n| `useCallback(fn, [dep])` | `UseCallback(fn, dep)` |\n| `useRef(v)` | `UseRef(v)` |\n| callback ref \u002F `ref={node => …}` | `UseElementRef\u003CT>()` + `.Ref(r)` |\n| `useContext(Ctx)` | `UseContext(Ctx)` |\n| `\u003CProvider value={x}>{c}\u003C\u002FProvider>` | `c.Provide(Ctx, x)` |\n| `\u003Cdiv>` (linear layout) | `FlexColumn(...)` \u002F `FlexRow(...)` (CSS-flexbox semantics) |\n| `\u003Cdiv>` (shrink-wrap) | `VStack(...)` \u002F `HStack(...)` |\n| `\u003Cspan>text\u003C\u002Fspan>` | `TextBlock(\"text\")` |\n| `\u003Ch1>` \u002F `\u003Ch2>` \u002F small caption | `Heading(...)` \u002F `SubHeading(...)` \u002F `Caption(...)` |\n| `\u003Cbutton onClick={fn}>` | `Button(\"label\", fn)` |\n| `\u003Cinput value={v} onChange={e=>…}>` | `TextBox(v, setV)` |\n| `\u003Cselect>` | `ComboBox(items, index, setIndex)` |\n| `\u003Cinput type=\"checkbox\">` | `CheckBox(checked, setChecked)` |\n| `{cond && \u003CX\u002F>}` | `cond ? X() : null` (null children are filtered) |\n| `{a ? \u003CX\u002F> : \u003CY\u002F>}` | `a ? X() : Y()` |\n| `{items.map(i => \u003CCard key={i.id} … \u002F>)}` | `items.Select(i => Component\u003CCard,…>(…).WithKey(i.id)).ToArray()` |\n| `\u003CCard {...props} \u002F>` | `Component\u003CCard, CardProps>(new CardProps(...))` |\n| `key={i.id}` | `.WithKey(i.id)` |\n| `className=\"...\"` (style) | `.Background(...)`, `.Padding(...)`, `.Margin(...)`, etc. |\n| `style={{margin: 10}}` | `.Margin(10)` |\n| `display: flex; flex: 1` | `FlexRow(...)` \u002F `.Flex(grow: 1, basis: 0)` |\n| `gap: 8` | `VStack(8, …)`, `FlexRow(...) with { ColumnGap = 8 }` (FlexColumn → `RowGap`) |\n| React Query `useQuery` \u002F `useMutation` | `UseResource` \u002F `UseMutation` (see `reactor-async`) |\n| JSX | C# method calls + `using static Microsoft.UI.Reactor.Factories` |\n\n**One important difference:** in Reactor, `UseState` with a `List\u003CT>` won't re-render on `.Add()` — same reference. Use `UseReducer` for lists (just like `useReducer` is preferred in React for complex state).\n\n\n> **Controlled prop note:** the factories shown here still take plain values\n> (`TextBox(text, setText)`, `Slider(value, ...)`) and wrap them for you.\n> Element-record properties behind those factories use `Optional\u003CT>` so\n> `Optional\u003CT>.Unset` can mean \"the control owns this value\". See\n> [`migration\u002F050-optional-t.md`](..\u002F..\u002F..\u002F..\u002Fdocs\u002Fguide\u002Fmigration\u002F050-optional-t.md).\n\n## Starting a new app\n\n`dotnet new reactor -n \u003CName>` scaffolds the canonical shape: `App.cs` (entry point + initial component, with the `using` block at the top) plus `\u003CName>.csproj`. Richer shells: `reactor-mvu`, `reactor-navview`, `reactor-tabview`. See the anti-probe + `mur check` notes under \"Use a `.csproj` …\" below for what comes out of the scaffold.\n\nFor a single-file `dotnet run App.cs` demo (no `.csproj`), `dotnet new reactor-singlefile -n \u003CName>` scaffolds `\u003CName>\u002F\u003CName>.cs` with the file-level `#:package` \u002F `#:property` header already in place. Keep all the code in that file, because a file-based app compiles only that one file. Check it with `mur check \u003CName>.cs` from its folder; a bare `mur check` builds the current directory, which needs a project file. To add the header to an existing file instead, see `reactor-build-and-check`'s single-file-scripts section.\n\nIf `dotnet new` rejects `--packaging` or can't find `reactor-singlefile`, the installed pack predates them; `winapp new --list --template-version latest` updates it.\n\n## Use a `.csproj` when you need …\n\n… multiple files, **analyzers** (single-file `.cs` builds don't load them), or shared project references. `dotnet new reactor` scaffolds the canonical csproj — you don't need to author one from scratch.\n\n`UseWinUI` MUST be `true`. **No XAML files of any kind.**\n\n**Don't change the packaging mode of a project you didn't scaffold — keep whatever the scaffold\nproduced.** Reactor works in both shapes:\n\n- **Unpackaged** — `\u003CWindowsPackageType>None\u003C\u002FWindowsPackageType>`, no `Package.appxmanifest`.\n  `None` wins over `EnableMsixTooling`, so a project carrying both still builds unpackaged. Runs\n  from any folder, no MSIX registration. Scaffold it with `dotnet new reactor --packaging Unpackaged`\n  (the other project templates take `--packaging` too).\n- **Packaged** — has a `Package.appxmanifest`. Either omit `WindowsPackageType` entirely (the\n  default produces a packaged app) or set it to `MSIX`; pair it with `EnableMsixTooling=true` for\n  the single-project MSIX tooling. Launches with package identity, which is what identity-gated\n  APIs require. This is what the `dotnet new reactor` family produces by default.\n\nNeither is \"the\" Reactor shape, and neither is signalled by one property alone. **If a project has a\n`Package.appxmanifest`, it is packaged on purpose — adding\n`\u003CWindowsPackageType>None\u003C\u002FWindowsPackageType>` to it silently strips its identity, and the build\nstill succeeds, so nothing surfaces the mistake.** Switch modes only when the user asks, and switch\nthe whole property *set*, not a single flag — the `packaging` guide has both shapes in full,\nincluding the explicit-`MSIX` form.\n\n**After `dotnet new reactor -n \u003CName>`, the source you edit is `App.cs` (entry point + initial component) next to `\u003CName>.csproj`.** The templates also scaffold build and packaging inputs — `app.manifest`, `Assets\u002F`, `Properties\u002FlaunchSettings.json`, `Properties\u002FPublishProfiles\u002F`, `.vscode\u002F`, and `Package.appxmanifest` when packaged; those are not source — leave them alone. The scaffold's `AGENTS.md` holds WinApp CLI workflow notes (`winapp ui …`, `winapp find-ui --source reactor`); it complements this skill. There is no `Program.cs` and no `GlobalUsings.cs` — modify `App.cs` in place. `App.cs` has its own `using` directives at the top — see the *Required imports* section below — and that is where you add new namespaces (e.g. `using System.Linq;` when you reach for `.Select(...)`). Some templates enable implicit usings, so a namespace may already be in scope. Don't probe the `.csproj` after scaffolding unless you're adding a `PackageReference` or changing a property — `Restore succeeded.` in the scaffold stdout is the only confirmation you need.\n\n**Scaffolded apps are packaged by default, so `dotnet run` launches them with MSIX package identity** — the F5 equivalent. That needs **Developer Mode on** (Settings → System → For developers) to register the loose-layout package, and a concrete architecture (the template declares `x86;x64;ARM64`; AnyCPU is rejected). A `--packaging Unpackaged` scaffold runs as a plain `.exe` with no package registration, so it doesn't need Developer Mode.\n\n**The scaffolded csproj ships a Debug-only ItemGroup that adds `Microsoft.UI.Reactor.Devtools` + `Reactor.DevtoolsSupport=true`.** That makes devtools available without turning them on. For the in-app dev menu, run `dotnet run -- --devtools app` and make sure the app renders `DevtoolsMenu(...)`, e.g. in its title bar — the flag alone draws nothing. `dotnet run` hands everything after `--` to the app, and a packaged scaffold still receives it when it launches with package identity. Keep the `app`: a bare `--devtools` is read as `--devtools run`, the heavier session behind `mur devtools` that also starts an MCP endpoint. `Properties\u002FlaunchSettings.json` depends on the packaging. A packaged scaffold lists a **Package** profile first, Visual Studio's F5 default, and an **Unpackaged** profile second. `dotnet run` can't apply MSIX profiles, so it picks **Unpackaged**, but WinApp still launches the app with package identity. WinApp also supplies its own run arguments, so `dotnet run` ignores profile arguments there; pass `-- --devtools app` yourself. In Visual Studio, keep **Package**: choosing **Unpackaged** there starts the exe without identity, and it fails at startup with `REGDB_E_CLASSNOTREG`. A `--packaging Unpackaged` scaffold has an **Unpackaged** profile plus an **Unpackaged, Devtools** profile that passes `--devtools app`. Release builds drop the devtools package and host-config switch so trim \u002F AOT analyzers stay quiet — see the `packaging` guide for the full rationale before flipping either knob.\n\n**Verify your edits with `mur check`** before declaring done. From the project directory: `mur check` (no arguments) runs `dotnet build` and emits one compressed line per diagnostic with a `→ try:` suggestion when the engine recognizes the mistake; `mur check --final` is the explicit \"I am done iterating\" sweep that emits the full diagnostic set including suppressed iteration-mode warnings. For anything more involved than the build\u002Ffix loop — strict-mode failures, custom diagnostic gating, MSBuild passthrough flags — load the `reactor-build-and-check` skill.\n\n## Required imports\n\n```csharp\nusing System;\nusing Microsoft.UI.Reactor;\nusing Microsoft.UI.Reactor.Core;\nusing Microsoft.UI.Reactor.Layout;   \u002F\u002F FlexDirection, FlexJustify, FlexAlign\nusing Microsoft.UI.Xaml;             \u002F\u002F Thickness, HorizontalAlignment, VerticalAlignment\nusing Microsoft.UI.Xaml.Controls;    \u002F\u002F Orientation, InfoBarSeverity, etc.\nusing static Microsoft.UI.Reactor.Factories;\n```\n\n## Components\n\n```csharp\n\u002F\u002F Class component (primary)\nclass Counter : Component\n{\n    public override Element Render()\n    {\n        var (count, setCount) = UseState(0);\n        return VStack(TextBlock($\"Count: {count}\"),\n                      Button(\"+1\", () => setCount(count + 1)));\n    }\n}\n\n\u002F\u002F Function component (inline, small reusable pieces)\nvar toggle = Memo(ctx =>\n{\n    var (on, setOn) = ctx.UseState(false);\n    return ToggleSwitch(on, setOn);\n});\n\n\u002F\u002F Typed props — use records for free structural equality\nrecord UserCardProps(string Name, string Role);\nclass UserCard : Component\u003CUserCardProps>\n{\n    public override Element Render() =>\n        VStack(TextBlock(Props.Name), Caption(Props.Role));\n}\nComponent\u003CUserCard, UserCardProps>(new UserCardProps(\"Alice\", \"Admin\"))\n\n\u002F\u002F Memoized function component\nMemo(ctx => TextBlock(\"Stable\"))               \u002F\u002F render once + own state\nMemo(ctx => TextBlock($\"Hi, {name}\"), name)    \u002F\u002F re-render when deps change\n```\n\n`Component` skips parent-triggered re-renders by default. `Component\u003CTProps>` skips when `Equals(oldProps, newProps)`.\n\n**App entry point.** `ReactorApp.Run\u003CMyRoot>(\"Title\", width: W, height: H)` against a component class (the scaffolded form). `width`\u002F`height` are optional DIPs — omit them to let the OS choose the initial window size. For a tiny demo without a class, the inline form: `ReactorApp.Run(\"Title\", ctx => { var (m, setM) = ctx.UseState(\"hi\"); return TextBlock(m); })`.\n\n## Hooks\n\n**Rules:** same order every render (no hooks in `if`\u002F`for`), only from `Render()` or function-component body.\n\n| Hook | Returns | Use for |\n|---|---|---|\n| `UseState\u003CT>(initial)` | `(T, Action\u003CT>)` | Primary state |\n| `UseReducer\u003CT>(initial)` | `(T, Action\u003CFunc\u003CT,T>>)` | State derived from previous (lists) |\n| `UseReducer\u003CTState,TAction>(reduce, initial)` | `(TState, Action\u003CTAction>)` | Action-style reducer |\n| `UseEffect(action, deps)` | — | Side effects + cleanup |\n| `UseMemo\u003CT>(factory, deps)` | `T` | Memoized computation |\n| `UseCallback(action, deps)` | `Action` | Stable callback reference |\n| `UseRef\u003CT>(initial)` | `Ref\u003CT>` | Mutable ref across renders (access via `.Current`) |\n| `UseObservable\u003CT>(source)` | `T` | Track `INotifyPropertyChanged` |\n| `UseExternalStore\u003CTSnapshot>(subscribe, getSnapshot)` | `TSnapshot` | Subscribe to an external store (stable `subscribe`, cached snapshot) |\n| `UseCollection\u003CT>(coll)` | `IReadOnlyList\u003CT>` | Track `ObservableCollection` |\n| `UseContext\u003CT>(ctx)` | `T` | Read tree-scoped ambient state |\n| `UsePersisted\u003CT>(key, initial)` | `(T, Action\u003CT>)` | State that survives unmount |\n| `UseResource\u003CT>` \u002F `UseInfiniteResource` \u002F `UseMutation` | (see `reactor-async`) | Async data |\n| `UseValidationContext()` | `ValidationContext` | (see `reactor-forms`) |\n| `UseNavigation\u003CTRoute>(initial)` | `NavigationHandle\u003CTRoute>` | (see `reactor-navigation`) |\n\n### UseState\n\n\u003C!-- index:use-state -->\n`UseState\u003CT>(initial)` returns `(value, setValue)`. Calling the setter with a\nvalue that differs from the current one schedules a re-render; the new value is\nvisible on the *next* render, not on the line after the call.\n\n```csharp\nvar (count, setCount) = UseState(0);\n\nreturn VStack(8,\n    TextBlock($\"Count: {count}\"),\n    Button(\"Increment\", () => setCount(count + 1)));\n```\n\nTwo rules decide whether `UseState` is the right hook:\n\n- **Hook order is constant.** Never call a hook inside `if`, `for`, or a\n  nested lambda — call them all unconditionally and use the result\n  conditionally. `REACTOR_HOOKS_001` enforces this.\n- **Reference types need a new instance.** `UseState(new List\u003CT>())` followed\n  by `list.Add(item)` will not re-render: the reference is unchanged, so the\n  setter never sees a difference. Reach for `UseReducer` instead.\n\nPass `threadSafe: true` when the setter is called from a background thread.\n\u003C!-- \u002Findex:use-state -->\n\n### UseReducer\n\n\u003C!-- index:use-reducer -->\n`UseReducer` is the hook for state derived from the previous value — above all\ncollections, where `UseState` silently fails to re-render because the mutated\nlist is the same reference.\n\n```csharp\nvar (items, updateItems) = UseReducer(new List\u003Cstring>());\n\nupdateItems(list => [.. list, \"New item\"]);   \u002F\u002F always a NEW list\n```\n\nThe updater receives the current value and returns the next one, so it is\ncorrect even when several updates are queued in one tick — unlike\n`setItems(items.Concat(...))`, which reads a captured `items` that may\nalready be stale.\n\nThe two-type-parameter overload takes an explicit reducer for action-style\nstate machines:\n\n```csharp\nvar (state, dispatch) = UseReducer\u003CBoardState, BoardAction>(Board.Reduce, BoardState.Initial);\n```\n\u003C!-- \u002Findex:use-reducer -->\n\n### UseEffect\n\n\u003C!-- index:use-effect -->\n`UseEffect(action, deps)` runs *after* the render commits. Return an `Action`\nto register cleanup — it runs before the next execution of the effect and once\nmore on unmount, which is what makes timers, subscriptions, and event handlers\nsafe to own from a component.\n\n```csharp\nvar (ticks, bumpTicks) = UseReducer(0);\n\nUseEffect(() =>\n{\n    var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };\n    timer.Tick += (_, _) => bumpTicks(t => t + 1);\n    timer.Start();\n    return () => timer.Stop();     \u002F\u002F cleanup on dep change and on unmount\n}, Array.Empty\u003Cobject>());\n```\n\nDependency rules:\n\n- Deps are a `params` argument, so `UseEffect(fn)` and\n  `UseEffect(fn, Array.Empty\u003Cobject>())` are the same call: empty deps compare\n  equal on every later render, so the effect runs **once, on mount**.\n- One or more deps → re-runs whenever any of them compares unequal.\n- **A freshly allocated object or lambda is never equal to the previous one**, so\n  it defeats the comparison and the effect re-runs every commit. (A type with\n  value-based `Equals`, such as a `record`, is the exception.)\n- **A lone reference-type array is the other exception** — it is treated as a\n  dependency *list* and compared element-wise, so `new[] { a, b }` re-allocated\n  each render with equal contents is stable.\n- **Tuple deps are rejected by the analyzer, not by the runtime.** A `ValueTuple`\n  of value types compares by value, so `(x, y)` would work — but\n  `REACTOR_HOOKS_004` classifies every tuple expression as an unstable dep and\n  fails the build. Use a string key such as `$\"{x}|{y}\"`, or separate deps:\n  `UseEffect(fn, x, y)`.\n\u003C!-- \u002Findex:use-effect -->\n\n### UseMemo and UseCallback\n\n\u003C!-- index:use-memo -->\n`UseMemo\u003CT>(factory, deps)` caches the result of an expensive computation and\nrecomputes it only when a dependency changes. `UseCallback(action, deps)` does\nthe same for a delegate, so a child that compares handlers by reference is not\nre-rendered by a freshly allocated lambda.\n\n```csharp\nvar sorted = UseMemo(() => items.OrderBy(i => i.Name).ToList(), items);\nvar onReset = UseCallback(() => setQuery(\"\"), Array.Empty\u003Cobject>());\n```\n\nBoth obey the same dependency rule as `UseEffect`: a fresh **object** or\n**lambda** allocated during render is never equal to the previous one and defeats\nthe cache entirely (a `record` is the exception, and a lone reference-type array\nis treated as a dependency *list* and compared element-wise, so equal contents\nstay stable). A tuple expression — though value-equal at runtime — is rejected\noutright by `REACTOR_HOOKS_004`. Memoize the computation, not the render —\n`UseMemo` is for work that is measurably expensive, not for every projection.\n\u003C!-- \u002Findex:use-memo -->\n\n### UseRef\n\n\u003C!-- index:use-ref -->\n`UseRef\u003CT>(initial)` returns a `Ref\u003CT>` — a mutable box that survives re-renders\nand, unlike `UseState`, **never triggers one**. Use it for values a render does\nnot read: a timer handle, a subscription token, a \"did I already do this\" flag,\nor a high-frequency value written during a gesture.\n\n```csharp\nvar timerRef = UseRef\u003CDispatcherTimer?>(null);\n\ntimerRef.Current = new DispatcherTimer();   \u002F\u002F .Current is the property — NOT .Value\ntimerRef.Current.Start();\n```\n\n`Ref\u003CT>` is Reactor's own box and exposes `.Current`. Do not confuse it with\n`ElementRef` \u002F `UseElementRef\u003CT>`, which points at a realized WinUI element and\nis populated by the reconciler rather than by you.\n\u003C!-- \u002Findex:use-ref -->\n\n### UseContext\n\n\u003C!-- index:context -->\nA `Context\u003CT>` passes ambient state down the tree without threading it through\nevery intermediate component. Declare the context once as a static, provide a\nvalue on an ancestor with `.Provide(...)`, and read it with `UseContext`.\n\n```csharp\npublic static readonly Context\u003Cstring> ThemeCtx = new(\"light\");\n\n\u002F\u002F Provide — every descendant sees \"dark\"\nVStack(8, Component\u003CToolbar>(), Component\u003CBody>()).Provide(ThemeCtx, \"dark\")\n\n\u002F\u002F Consume, anywhere below\nvar theme = UseContext(ThemeCtx);\n```\n\nThe value passed to `new Context\u003CT>(...)` is the default a consumer reads when\nno ancestor provides one, so `UseContext` never returns an unexpected `null`.\nProviding a new value re-renders the consumers below it, not the whole tree.\n\u003C!-- \u002Findex:context -->\n\n## Common factories — the 90% cases\n\nThe full catalog (every factory, modifier, enum) is in `references\u002Freactor.api.txt`. The signatures below cover most apps; consult the index when you need a control not listed here.\n\n```csharp\n\u002F\u002F Layout\nVStack(spacing, children...)                  HStack(spacing, children...)\nFlexColumn(children...)                       FlexRow(children...)\n\u002F\u002F Prefer FlexRow\u002FFlexColumn for linear layout — CSS Flexbox semantics\n\u002F\u002F (grow\u002Fshrink\u002Fgap\u002Fwrap, justify-content, align-items). VStack\u002FHStack\n\u002F\u002F remain for StackPanel's shrink-wrap behavior.\nBorder(child).CornerRadius(8).Background(Theme.CardBackground).Padding(16)\nScrollView(VStack(...))      \u002F\u002F modern (default); ScrollViewer(...) is the classic Control\nGrid(columns: [GridSize.Star(), GridSize.Px(200)],\n     rows:    [GridSize.Auto,   GridSize.Star()],\n    TextBlock(\"Header\").Grid(row: 0, column: 0, columnSpan: 2),\n    ListView(items, ...).Grid(row: 1, column: 0),\n    Sidebar().Grid(row: 1, column: 1))\nTitleBar(\"App\") with { Subtitle = \"Home\", Content = ..., RightHeader = ... }\nContentDialog(string title, Element content, string primaryButtonText = \"OK\")\nFlyout(Element target, Element content)\nNavigationView(items, content) with { SelectedTag = \"home\", IsPaneOpen = true }\n\n\u002F\u002F Text\nTextBlock(\"hi\")        Heading(\"Title\")        SubHeading(\"Section\")        Caption(\"note\")\n\u002F\u002F Strings auto-convert to TextBlockElement: VStack(\"A\", \"B\") works.\n\n\u002F\u002F Controls\nButton(\"Click\", () => ...)                                    \u002F\u002F positional: (label, onClick)\nButton(\"Save\", onClick: handler).Background(Theme.Accent)     \u002F\u002F named-arg form before modifiers\n\u002F\u002F `onClick` is a Button ctor parameter — NOT a chained `.OnClick(...)` \u002F\n\u002F\u002F `.OnTapped(...)`. `.OnTapped` is a gesture event with different input\n\u002F\u002F semantics (long-press, touch, pen) and is the wrong fix for click intent.\nTextBox(value, setValue, placeholderText: \"...\")\nCheckBox(isChecked, onChanged: setChecked, label: \"label\")\nToggleSwitch(on, setOn)\nSlider(v, 0, 100, setV)\nComboBox(items, selectedIndex, setIndex)\nProgressIndeterminate()                  ProgressRing()\nInfoBar(\"Title\", \"message\").Severity(InfoBarSeverity.Error)\n\n\u002F\u002F Lists \u002F templated\nListView\u003CT>(items, keySelector, viewBuilder)\nGridView\u003CT>(items, keySelector, viewBuilder)\nDataGrid\u003CT>(source, columns, ...)        \u002F\u002F see reactor.api.txt for full signature\n\n\u002F\u002F Conditional \u002F iteration\nisLoggedIn ? TextBlock($\"Hi, {name}\") : Button(\"Log in\", onLogin)\nVStack(TextBlock(\"always\"), showExtra ? TextBlock(\"maybe\") : null)   \u002F\u002F null filtered\nWhen(items.Any(), () => TextBlock($\"{items.Count} items\"))\nIf(isError, () => InfoBar(\"Error\", msg).Severity(InfoBarSeverity.Error),\n            () => TextBlock(\"OK\"))\nstatus switch {\n    Status.Loading => ProgressIndeterminate(),\n    Status.Error   => TextBlock(\"Oops\"),\n    Status.Success => Component\u003CSuccessView>(),\n    _ => Empty()\n}\nForEach(items, item => TextBlock(item.Name))\nitems.Select(i => Component\u003CCard, CardProps>(new CardProps(i)).WithKey(i.Id)).ToArray()\n\n\u002F\u002F Common modifiers\n.Margin(10)            .Margin(left: 8, top: 4, right: 8, bottom: 4)\n.Padding(16)           .Background(Theme.CardBackground)\n.Foreground(Theme.PrimaryText)\n.CornerRadius(8)       .WithBorder(Theme.CardStroke, 1)\n.Flex(grow: 1, basis: 0)        \u002F\u002F CSS `flex: 1` equivalent\n.WithKey(\"id\")                  \u002F\u002F dynamic list items — see gotcha #6\n.OnTapped((s, e) => ...)        \u002F\u002F tap on non-Button surfaces — Border, Image, ScrollView, …\n                                \u002F\u002F (Button click → ctor arg, see Controls section)\n                                \u002F\u002F ⚠️ For UIA\u002Fautomation: always pair with .AutomationName(\"...\")\n.AutomationName(\"Submit\")       \u002F\u002F a11y — sets AutomationProperties.Name\n.Ref(targetRef)                 \u002F\u002F bind an ElementRef\u003CT>; Compose FocusRequester \u002F React callback-ref shape\n.Target(targetRef)              \u002F\u002F reference prop, e.g. TeachingTip.Target; also .LabeledBy\u002F.XYFocusRight\n.Set(native => native.MaxWidth = 400)   \u002F\u002F native escape hatch (lambda receives the WinUI control)\n```\n\n## Theme tokens (always)\n\nUse `Theme.*` for all themed colors — never hardcoded hex on themed surfaces. The full token list with WinUI keys is in the `reactor-design` skill.\n\n> ⚠️ **`Theme.Error`, `Theme.Success`, `Theme.Warning`, `Theme.ErrorText` do NOT exist.**\n> Use `Theme.SystemCritical` (red\u002Ferror), `Theme.SystemSuccess` (green), `Theme.SystemCaution` (yellow).\n\n```csharp\nTextBlock(\"Hi\").Foreground(Theme.PrimaryText)\nBorder(child).Background(Theme.CardBackground).WithBorder(Theme.CardStroke, 1)\nButton(\"Action\").Background(Theme.Accent)\nTextBlock(\"Error!\").Foreground(Theme.SystemCritical)       \u002F\u002F NOT Theme.Error\nTextBlock(\"Saved\").Foreground(Theme.SystemSuccess)         \u002F\u002F NOT Theme.Success\n```\n\n## Critical gotchas\n\n1. **Hook order is constant.** No hooks inside `if`\u002F`for`. Call them all unconditionally; conditionally use the result.\n2. **Type-specific sugar before generic modifiers.**\n   `TextBlock(\"Hi\").Bold().Margin(10)` ✓ — `.Bold()` needs `TextBlockElement`.\n   `TextBlock(\"Hi\").Margin(10).Bold()` ✗ — `.Margin()` returns `Element`.\n3. **List mutations need `UseReducer`.** `UseState(new List\u003CT>())` + `list.Add()` won't re-render — same reference. Use `UseReducer(list => [.. list, item])`.\n4. **Null children are filtered.** `VStack(a, condition ? b : null, c)` is safe.\n5. **Records with `with` for init-only properties.** `NavigationView(items, content) with { SelectedTag = \"home\", IsPaneOpen = true }`.\n6. **`.WithKey(\"id\")` on dynamic list items.** Without keys, the reconciler matches by position and re-mounts everything on insert\u002Freorder — losing focus, animation state, ElementRef identity. The `REACTOR_DSL_001` analyzer catches this in `.csproj` builds.\n7. **Memoize expensive computations.** `UseMemo(() => items.OrderBy(...).ToList(), items)`.\n8. **`.Flex(grow: 1)` is `flex-grow`, not the CSS `flex: 1` shorthand.** Default basis is `auto` (content size), so a growing child with large intrinsic content overflows the container. Pass `.Flex(grow: 1, basis: 0)` (matches CSS `flex: 1`) or add `.Flex(shrink: 0)` to each fixed-size sibling.\n9. **Don't pass freshly-allocated objects\u002Farrays\u002Flambdas as hook deps.** They compare unequal every render → hook never hits its stable path. The `REACTOR_HOOKS_004` analyzer catches this. **Tuples are also rejected** — not because `(x, y)` compares unequal (a `ValueTuple` of value types is value-equal), but because the analyzer classifies every tuple expression as an unstable dep. Instead, use a string key: `$\"{x}|{y}\"`, or pass individual values as separate deps: `UseEffect(fn, x, y)`.\n10. **`UseResource` is reads-only.** Never call `Post*`\u002F`Create*`\u002F`Delete*`\u002F`Save*` from a `UseResource` fetcher — it can re-run on deps change, retry, and focus revalidation. Use `UseMutation` for writes.\n\n### Element refs and reference props\n\nUse `UseElementRef\u003CT>()` when one element needs to point at another real\nWinUI element. Attach the cell with `.Ref(...)`, then pass it to a\nreference prop such as `TeachingTip.Target`, `.LabeledBy(...)`, or\n`.XYFocusRight(...)`. This is Reactor's callback-ref \u002F Compose\n`FocusRequester` shape: the graph updates when the target mounts late,\nunmounts, or is recreated.\n\n```csharp\nvar target = this.UseElementRef\u003CFrameworkElement>();\n\nreturn HStack(\n    Button(\"Show tip\", () => setOpen(true)).Ref(target),\n    TeachingTip(\"Hint\", target: target) with { IsOpen = open });\n```\n\nDo **not** set relationship properties by reading `target.Current` in a\nhandler; use the reference prop so Reactor can clear and re-resolve it.\n\n## Common patterns (paste-ready)\n\nThese cover the bulk of \"stateful app with lists, dialogs, and per-row actions\" — copy and adapt rather than re-deriving from the api index.\n\n### Drag and drop (typed payload between two lists)\n\n```csharp\nusing Microsoft.UI.Reactor.Input;   \u002F\u002F DragOperations, DragData\n\nsealed record Item(string Id, string Title);\n\nElement RenderList(string title,\n                   IReadOnlyList\u003CItem> items,\n                   Action\u003CIReadOnlyList\u003CItem>> setThis)\n{\n    var children = new List\u003CElement> { TextBlock(title).SemiBold() };\n\n    foreach (var item in items)\n    {\n        var captured = item;                                         \u002F\u002F capture for the lambda\n        children.Add(\n            Border(TextBlock(captured.Title))\n                .Background(Theme.CardBackground).CornerRadius(6).Padding(10)\n                .OnDragStart\u003CBorderElement, Item>(\n                    getPayload: () => captured,\n                    allowedOperations: DragOperations.Move,\n                    onEnd: ctx =>\n                    {\n                        \u002F\u002F Move-on-confirmation: only remove after a confirmed Move\n                        \u002F\u002F (not on cancel or Copy). Avoids the source losing data\n                        \u002F\u002F if the drop target rejects.\n                        if (!ctx.WasCancelled && ctx.CompletedOperation == DragOperations.Move)\n                            setThis(items.Where(i => i.Id != captured.Id).ToList());\n                    })\n        );\n    }\n\n    return VStack(6, children.ToArray())\n        .OnDrop\u003CStackElement, Item>(\n            onDrop: dropped =>\n            {\n                if (!items.Any(i => i.Id == dropped.Id))\n                    setThis(items.Append(dropped).ToList());\n            },\n            acceptedOps: DragOperations.Move);\n}\n```\n\nFor cross-process text drag (drop into Notepad\u002FWord): use `.OnDragStart\u003CBorderElement>(() => new DragData().WithText(\"...\"))` and `.OnDrop\u003CBorderElement>(args => args.Data.TryGetText(out var t))`.\n\n### ContentDialog (modal — confirm, edit, alert)\n\n`ContentDialog` is a render-tree element with `IsOpen`\u002F`OnClosed` driven by component state — same pattern as React. Don't try to imperatively `.ShowAsync()`; let the reconciler manage it.\n\n```csharp\nvar (showConfirm, setShowConfirm) = UseState(false);\nvar (lastResult, setLastResult) = UseState(\"(none)\");\n\nVStack(8,\n    Button(\"Delete item\", () => setShowConfirm(true)),\n    TextBlock($\"Last result: {lastResult}\").Foreground(Theme.SecondaryText),\n\n    ContentDialog(\"Confirm delete\",\n                  TextBlock(\"Are you sure? This cannot be undone.\"),\n                  primaryButtonText: \"Delete\") with\n    {\n        IsOpen = showConfirm,\n        SecondaryButtonText = \"Cancel\",\n        OnClosed = result =>\n        {\n            setLastResult(result.ToString());\n            setShowConfirm(false);\n        },\n    }\n)\n```\n\nFor an \"edit existing item\" dialog: lift the item being edited into state (`UseState\u003CItem?>(null)`); when non-null, render the dialog with `IsOpen = editing != null`; in `OnClosed` either commit the edit and clear, or just clear.\n\n### Flyout \u002F context menu (right-click, dropdown menu)\n\n```csharp\n\u002F\u002F Right-click context menu on any element\nBorder(TextBlock(\"Right-click me\"))\n    .Padding(12).Background(Theme.SubtleFill).CornerRadius(6)\n    .WithContextFlyout(MenuItems(\n        MenuItem(\"Edit\",      () => beginEdit(item)),\n        MenuItem(\"Duplicate\", () => duplicate(item)),\n        MenuSeparator(),\n        MenuItem(\"Delete\",    () => delete(item))\n    ))\n\n\u002F\u002F Dropdown button with a menu\nDropDownButton(\"Sort\", flyout: MenuItems(\n    MenuItem(\"By name\", () => setSort(Sort.Name)),\n    MenuItem(\"By date\", () => setSort(Sort.Date)),\n    MenuSeparator(),\n    MenuItem(\"Reverse\", () => setSort(s => s.Reversed()))\n))\n\n\u002F\u002F Click flyout with custom content (vs. menu items)\nButton(\"Open flyout\", null).WithFlyout(ContentFlyout(\n    VStack(8,\n        TextBlock(\"Custom content here\").SemiBold(),\n        Slider(value, 0, 100, setValue)),\n    placement: Microsoft.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.Bottom\n))\n```\n\n### Context (dispatch \u002F theme passed without prop drilling)\n\nWhen many descendants need `dispatch(action)` or a theme value, define `Context\u003CT>` once and `.Provide(...)` from a parent. Same shape as React's `createContext` + `useContext`.\n\n```csharp\n\u002F\u002F At module\u002Fclass scope\nsealed record AppAction(string Name);\nstatic readonly Context\u003CAction\u003CAppAction>> DispatchCtx = new(_ => { });\n\n\u002F\u002F At the root\nclass App : Component\n{\n    public override Element Render()\n    {\n        var (state, dispatch) = UseReducer\u003CAppState, AppAction>(App.Reduce, AppState.Initial);\n\n        return VStack(\n            Heading(\"My app\"),\n            Component\u003CChildView>()\n        ).Provide(DispatchCtx, dispatch);     \u002F\u002F descendants can read this\n    }\n}\n\n\u002F\u002F Anywhere in the subtree\nclass ChildView : Component\n{\n    public override Element Render()\n    {\n        var dispatch = UseContext(DispatchCtx);\n        return Button(\"Do thing\", () => dispatch(new AppAction(\"ThingClicked\")));\n    }\n}\n```\n\nNested `.Provide()` overrides the outer for its subtree only. If no provider is present, `UseContext` returns the `Context\u003CT>` default.\n\n## Bootstrap\n\n`mur pack-local` (selfhost) and `nuget.config` (consumer outside the source clone) — see the top-level `SKILL.md`'s \"Which mode are you in?\" section. If selfhost restore fails with \"package Microsoft.UI.Reactor 0.0.0-local was not found\", run `mur pack-local`.\n\n> ⚠️ **Platform flag required when working *inside this repo* (selfhost)**: always build samples \u002F in-repo projects with an explicit platform: `dotnet build -p:Platform=x64` (or `ARM64`). Omitting `-p:Platform=...` causes `WindowsAppSDKSelfContained` errors. This applies to `dotnet build`, `dotnet run`, and `mur check` invocations alike.\n>\n> The `dotnet new reactor` template auto-resolves `RuntimeIdentifier` from the host SDK when `Platform`\u002F`RuntimeIdentifier` aren't explicit, so consumer projects scaffolded outside the repo build with bare `dotnet build` \u002F F5 — the rule above only applies in the selfhost tree.\n\n## Where the skill content comes from (and the api index)\n\nYou're reading this through the **`reactor` plugin** — the most efficient channel. The plugin SDK preloads `reactor-getting-started`; topical skills (`reactor-async`, `reactor-design`, `reactor-forms`, `reactor-navigation`, `reactor-input`, `reactor-recipes`, `reactor-wrapping` for turning any WinUI, vendor, or custom control into a declarative element via the `[GenerateReactorWrapper]` source generator, `reactor-advanced` for Win2D canvases via the optional `Microsoft.UI.Reactor.Advanced` package, etc.) load only when the task explicitly needs them.\n\nFull API index (every factory, modifier, hook, theme token, with parameter lists): `references\u002Freactor.api.txt` inside the `reactor-dsl` skill (also bundled into the Microsoft.UI.Reactor nupkg's `agentkit\u002F` tree if you need to find it from a consumer).\n\n**Read the api index once** when you need to confirm an unusual signature — it's ~12K tokens, but cheaper than the equivalent number of grep+read cycles. Don't re-read pages of it; cache what you need in your working memory.\n\n## Build output\n\n`dotnet run` exits with code 1 on build failure. **Always read the output** — don't assume success. After non-trivial edits, run `mur check \u003Cpath>` for one-line diagnostics with skill-file pointers (see `reactor-build-and-check`).\n\n> Remember: always pass `-p:Platform=x64` (or `ARM64`). Without it, the first build always fails.\n",{"name":5,"description":7},"main","587dd6ae61699a11cd5e7fe5be123c8d8e0f1812","plugins\u002Freactor\u002Fskills\u002Freactor-getting-started",67,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-15 01:08:04",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add microsoft\u002Fmicrosoft-ui-reactor --skill reactor-getting-started",{"tool":67,"command":68},"bunx","bunx skills add microsoft\u002Fmicrosoft-ui-reactor --skill reactor-getting-started",{"tool":70,"command":71},"pnpm","pnpm dlx skills add microsoft\u002Fmicrosoft-ui-reactor --skill reactor-getting-started","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor\u002Fblob\u002Fmain\u002Fplugins\u002Freactor\u002Fskills\u002Freactor-getting-started\u002FSKILL.md",true,[],[76,82,110,135,159,182],{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":47},"01M69B94E15PYYWXAGFV832MRK","Charting","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor\u002Fblob\u002Fmain\u002Fsrc\u002FReactor.Advanced\u002FCharting\u002Fskill.md",[],[78],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":47},"01M69B92C846XMSNJ4PZGVYY3C","reactor-wrapping","Turn ANY WinUI control — a vendor\u002Fthird-party control, your own custom Control, or a Windows Community Toolkit one — into a first-class declarative Reactor element with the [GenerateReactorWrapper] source generator, zero hand-written wrapper code. Covers auto-inference (props, content, two-way pairs, panel\u002Fitems children, events), the [Wrap*] annotation cheat-sheet, imperative-lifecycle controls, diagnostics, and when to fall back to a hand-written ControlDescriptor.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor\u002Fblob\u002Fmain\u002Fplugins\u002Freactor\u002Fskills\u002Freactor-wrapping\u002FSKILL.md",[],[89,90,91,92,93,94,95,29,96,97,98,99,100,101,102,103,104,105,106,107,108,109],"reactor wrapping","declarative","with","hand","code","cheat","generator","auto","controls","custom","element","lifecycle","winui","ZeRO","panel","community","back","inference","diagnostics","toolkit","windows",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":47},"01M69B90PW92BQ4YNZYTP4SERB","reactor-windowing","Reactor top-level windowing cookbook: WindowSpec, OpenWindow, draggable windows, borderless\u002Ftool windows, placement persistence, taskbar visibility, z-order, aspect ratio, SizeToContent, displays, taskbar integration, and owner-window file\u002Ffolder pickers.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor\u002Fblob\u002Fmain\u002Fplugins\u002Freactor\u002Fskills\u002Freactor-windowing\u002FSKILL.md",[],[117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,109,132,133,134],"reactor windowing","progress","persistence","cookbook","integration","folder","command","command palette","top","window","palette","file","restore","open","tool","remember","position","make",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":47},"01M69B8Y5Y0VKXADXCN3W1NK89","reactor-recipes","Paste-ready single-file Reactor recipes indexed by intent — list with add\u002Fdelete\u002Ftoggle, sidebar navigation between pages, form with validation + submit gating, async fetch with loading\u002Ferror\u002Fdata states, themed Win11 card surface. Use a recipe instead of synthesizing from prose: copy, adjust, ship.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor\u002Fblob\u002Fmain\u002Fplugins\u002Freactor\u002Fskills\u002Freactor-recipes\u002FSKILL.md",[],[142,143,128,144,91,145,146,147,148,149,34,150,151,152,153,154,155,156,157,158],"reactor recipes","recipes","recipe","form","use","adjust","single","pages","card","submit","loading","states","fetch","gating","single-file","ready","error",{"skillNo":160,"name":161,"nameZh":6,"description":162,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":47},"01M69B8WNYS31M4P012P2QTX6R","reactor-navigation","Reactor navigation — `UseNavigation` hook, `NavigationHost` renderer, `NavigationView` sidebar, `TabView` tabs, route params, stack operations, page lifecycle, deep linking, transitions, caching. Use when building multi-page apps or wiring sidebar\u002Ftab navigation.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor\u002Fblob\u002Fmain\u002Fplugins\u002Freactor\u002Fskills\u002Freactor-navigation\u002FSKILL.md",[],[166,167,168,29,169,146,100,170,171,172,173,174,175,176,177,178,179,180,181],"navigation","reactor navigation","caching","apps","renderer","multi-page","page","deep","wiring","hook","operations","transitions","linking","stack","route","multi",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":188,"publishedAt":47},"01M69B8TGJA43N8X6BFVWTXC1H","reactor-input","Reactor input — gestures (`OnPan`, `OnPinch`, `OnRotate`), pointer events, drag-and-drop (`OnDragStarting`), focus management (`UseElementFocus`, `UseFocus`, `UseFocusTrap`). Use when implementing direct manipulation or custom focus behavior.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fmicrosoft-ui-reactor\u002Fblob\u002Fmain\u002Fplugins\u002Freactor\u002Fskills\u002Freactor-input\u002FSKILL.md",[],[189,190,191,192,193,194,195,196,29,146,98,197,198,199],"input","reactor input","direct","events","management","behavior","focus","drop","implementing","drag","gestures"]