csharp-winui
Installation
SKILL.md
C# and WinUI
The code is right when it builds with zero warnings, launches without a
CRASH line, and the app does what the story says. For how it should
look, call the Skill tool with windows-design. For copyable XAML, read
../../design/windows-design/patterns.md.
Threads
WinUI has one UI thread per window. Every control and every object bound to a control lives on it.
| Work | Put it in |
|---|---|
Pages, view models, ObservableCollections bound to lists |
The UI thread (the default in event handlers and OnLaunched) |
| CPU-heavy pure work (parsing, image work, diffing) | await Task.Run(() => ...), then set results back on the UI thread |
| File and database work | async methods; small SQLite calls on the UI thread are fine, anything over a few ms goes to Task.Run |
| A Win32 callback (hotkey, hook, timer from another thread) | Hop back with DispatcherQueue.TryEnqueue(() => ...) |