| name | demo-section-generator |
| description | Generates anchored DemoSectionView-based demo sections for pages in demo/Ursa.Demo/Pages using the AutoCompleteBox demo as the canonical pattern. |
| license | MIT |
Use this skill when asked to add or refactor demo sections for a control demo page.
Canonical references
Always mirror these patterns unless the user asks for a deviation:
demo/Ursa.Demo/Pages/AutoCompleteBoxDemo/AutoCompleteBoxDemo.axaml
demo/Ursa.Demo/Pages/AutoCompleteBoxDemo/AutoCompleteBoxDemoViewModel.cs
demo/Ursa.Demo/ViewModels/Controls/DemoSectionViewModel.cs
demo/Ursa.Demo/Controls/DemoSectionView.axaml
demo/Ursa.Demo/Controls/AnchorScrollViewer.cs
demo/Ursa.Demo/Themes/AnchorScrollViewer.axaml
reference/autocompletebox-demo-pattern.md in this skill folder
What to generate
For a target page <ControlName>Demo:
- Update
<ControlName>Demo.axaml to use:
- A Guide tab (
Tab_Header_Guide) when sectioned docs are being added.
<controls:AnchorScrollViewer AnchorItems="{Binding AnchorItems}">.
- One
<controls:DemoSectionView SectionContext="{Binding XxxSection}"> per section.
- Update
<ControlName>DemoViewModel.cs to add:
- Anchor ID constants (kebab-case string values).
DemoSectionViewModel properties (XxxSection naming).
- Constructor initialization for each section (
Header, SectionTag, Descriptions, AnchorId, and CodeSnippets).
AnchorItems entries aligned 1:1 with section headers and anchor IDs.
- Update localization resources:
- Add keys to
demo/Ursa.Demo/Localizations/Resources.resx.
- Add the same keys to every localized
.resx in the same folder:
Resources.cs-CZ.resx
Resources.de-DE.resx
Resources.fr-FR.resx
Resources.pl-PL.resx
Resources.ru-RU.resx
Resources.zh-Hans.resx
- Provide proper per-language translations. Do not copy English fallback text into non-English resource files unless the user explicitly requests it.
- Section content defaults (apply unless user asks otherwise):
- If the control supports style classes, add a dedicated style-class section tagged with
DemoSectionTag.Style, and explain what each class changes.
- If style classes can be switched interactively and there are multiple class groups, prefer using
ClassSelector to group class options and apply them to target controls.
- For selection controls, include a simple section that binds a string collection (
ObservableCollection<string>) for basic usage.
- For complex item types, demonstrate filtering and display together: use
ItemFilter and ItemTemplate in the same section so filtering behavior and rendering are explained as one workflow.
Naming and structure rules
- Follow key naming from AutoCompleteBox:
Page_<ControlName>_Section_<SectionName>_Header
Page_<ControlName>_Section_<SectionName>_Description
- Use
LanguageManager.Instance for section headers/descriptions and snippet tab names.
- Use
CodeLanguage.Axaml and CodeLanguage.CSharp for snippets where appropriate.
- Include at least one XAML snippet per section.
- Add a ViewModel (C#) snippet when the section relies on bindings, collections, predicates, or custom data structures.
- Keep
PageMetadata, doc attributes, and existing behavior intact unless explicitly requested otherwise.
- Ensure every section
AnchorId is unique and appears in both:
DemoSectionViewModel.AnchorId
AnchorItems entry
- Set
DemoSectionViewModel.SectionTag as an enum value:
DemoSectionTag.Function
DemoSectionTag.Style
DemoSectionTag.Others
Display text must be derived inside DemoSectionView from this enum via Lingua resources (LanguageManager.Instance.DemoSection_Tag_*).
Localization quality rules
- Translate all newly added section headers/descriptions in every locale file listed above.
- Reuse existing terminology in each locale (for example wording already used for "section", "usage", "style", "custom", etc.).
- Keep technical identifiers unchanged when needed (control names, enum names,
XAML, C#, EnumItemTuple).
- Ensure translated text is natural in the target language and semantically equivalent to English source text.
- Before finishing, confirm there are no new English-only values left in non-English resource files for the keys introduced by this task.
Implementation checklist
- Read the target page's existing
.axaml and ViewModel.cs.
- Add/adjust required namespaces (
controls, localizations, u, etc.).
- Wrap each demo block in
DemoSectionView.
- Add section metadata/snippets in the view model.
- Add section-appropriate snippets: XAML for every section, plus C# ViewModel snippets for data/binding/filter logic.
- If style classes are part of the control API, add a dedicated style section and use
ClassSelector grouping when practical.
- Sync
AnchorItems ordering with visual section ordering.
- Add localization keys for every section header/description in all locale files with proper translations.
- Validate by building only the demo project:
dotnet build demo/Ursa.Demo/Ursa.Demo.csproj.
- Do not run full repository build or test suites unless the user explicitly asks for them.