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.axamldemo/Ursa.Demo/Pages/AutoCompleteBoxDemo/AutoCompleteBoxDemoViewModel.csdemo/Ursa.Demo/ViewModels/Controls/DemoSectionViewModel.csdemo/Ursa.Demo/Controls/DemoSectionView.axamldemo/Ursa.Demo/Controls/AnchorScrollViewer.csdemo/Ursa.Demo/Themes/AnchorScrollViewer.axamlreference/autocompletebox-demo-pattern.mdin this skill folder
What to generate
For a target page <ControlName>Demo:
- Update
<ControlName>Demo.axamlto 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.
- A Guide tab (
- Update
<ControlName>DemoViewModel.csto add:- Anchor ID constants (kebab-case string values).
DemoSectionViewModelproperties (XxxSectionnaming).- Constructor initialization for each section (
Header,SectionTag,Descriptions,AnchorId, andCodeSnippets). AnchorItemsentries 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
.resxin the same folder:Resources.cs-CZ.resxResources.de-DE.resxResources.fr-FR.resxResources.pl-PL.resxResources.ru-RU.resxResources.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.
- Add keys to
- 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
ClassSelectorto 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
ItemFilterandItemTemplatein the same section so filtering behavior and rendering are explained as one workflow.
- If the control supports style classes, add a dedicated style-class section tagged with
Naming and structure rules
- Follow key naming from AutoCompleteBox:
Page_<ControlName>_Section_<SectionName>_HeaderPage_<ControlName>_Section_<SectionName>_Description
- Use
LanguageManager.Instancefor section headers/descriptions and snippet tab names. - Use
CodeLanguage.AxamlandCodeLanguage.CSharpfor 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
AnchorIdis unique and appears in both:DemoSectionViewModel.AnchorIdAnchorItemsentry
- Set
DemoSectionViewModel.SectionTagas an enum value:DemoSectionTag.FunctionDemoSectionTag.StyleDemoSectionTag.OthersDisplay text must be derived insideDemoSectionViewfrom 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
.axamlandViewModel.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
ClassSelectorgrouping when practical. - Sync
AnchorItemsordering 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.