Syncfusion WPF UI Builder
Overview
The Syncfusion WPF UI Builder skill is a desktop-only WPF control generator that orchestrates an AI agent through 8 stages to generate production-ready UI controls powered by Syncfusion.
What This Skill Does
✅ Generates (UI Layer):
- WPF XAML using Syncfusion controls + C# code-behind with MVVM pattern
- UI Automation accessibility markup (WCAG 2.1 AA)
- DPI-aware responsive layouts
- Client-side input validation and event handling
✅ Generates (Backend Layer):
- Service classes with business logic (e.g.,
AuthService, CustomerService)
- Repository interfaces and in-memory implementations
- Navigation / screen-transition logic
- Data models, DTOs, and ViewModel interfaces
❌ Does NOT Generate:
- Real database schemas, ORM migrations, or SQL
- Live third-party API integrations
- Authentication infrastructure (OAuth, JWT issuing)
- Environment secrets beyond
SYNCFUSION_LICENSE_KEY
Full-feature rule: Every generated screen must be end-to-end functional — UI wired to backend logic, validation active, and navigation working. Partial logic or stub-only output is not acceptable.
Quick Start
Prerequisites
- WPF project targeting .NET Framework 4.6.2+ or .NET 8+
- Visual Studio 2022+ with WPF workload
- Syncfusion WPF library (auto-installed if missing):
dotnet add package Syncfusion.SfGrid.WPF
- Node.js 14+ (required for Stage 3 BM25 control-mapping script)
Examples
Login Form
User: "Create a login form with email, password, and remember me checkbox"
Output:
✓ Views/LoginForm/LoginForm.xaml — SfTextInputLayout + SfButton
✓ Views/LoginForm/LoginForm.xaml.cs — event handling, navigation on success
✓ ViewModels/LoginViewModel.cs — INotifyPropertyChanged, ICommand
✓ Services/AuthService.cs — credential validation logic
✓ Models/LoginModel.cs — email, password, rememberMe fields
Customer Data Table
User: "Build a customer data table with sorting and filtering"
Output:
✓ Views/CustomerTable/CustomerTable.xaml — SfDataGrid with sort/filter
✓ ViewModels/CustomerTableViewModel.cs — ObservableCollection, filter logic
✓ Services/CustomerService.cs — data retrieval, search logic
✓ Models/CustomerModel.cs — typed model with sample data
Reusable Workflow Instructions
Key Architecture
| Property |
Detail |
| Design |
Stateless — conversation history is sole state store |
| Stages |
8 total (6 automated, 2 user-gated) |
| User gates |
Stage 3 (control confirmation) + Stage 4 (theming) |
| Auto-healing |
Stages 5A, 5B, 6A, 7 auto-fix errors before passing downstream |
| Hard block |
Stage 2A blocks on WPF/WinUI framework mismatch |
| Code scope |
Both UI and backend generated together as one complete feature |
Stage Execution Flow (Mandatory Order)
User Request
↓
[Stage 1] Intent Analysis
→ Parse query, identify control type & features, resolve ambiguities
→ Identify backend requirements (services, validation, navigation) implied by the screen
→ Read: references/stage-1-intent-analysis.md
→ Output: Control type + modifiers + target directory + backend scope summary
↓
[Stage 2] Project Detection
→ Auto-detect framework, .NET version, theming, project structure
→ Detect existing service/repository patterns to match generated backend style
→ Read: references/stage-2-project-detection.md
→ Output: Project config + user confirmation (with override option)
↓
[Stage 2A] Framework Consistency Guard ⛔ FAIL-FAST
→ Enforce WPF namespace: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
→ BLOCK if WPF/WinUI controls or namespaces are mixed
→ Output: Confirmed namespace declarations or halt with mismatch report
↓
[Stage 3] Layout Analysis & Control Mapping ⭐ USER GATE #1 + SCRIPT REQUIRED
→ Read: references/stage-3-layout-analysis.md
→ Read control-mapping.json to identify:
• Relevant Syncfusion controls for each UI element
• Associated skill reference files per control
→ Run BM25 script: node controls_search.cjs <project-root>/control-mapping.json
(cd <project-root>\.apm\skills\syncfusion-wpf-ui-builder\scripts first)
→ Map backend actions to each control (e.g., ButtonAdv[Login] → AuthService.ValidateAsync)
→ Output: control-mapping.json + Syncfusion control map + backend action map + user confirmation
↓
[Stage 4] Theming & Design System ⭐ USER GATE #2
→ Read: references/stage-4-theming-and-design-system.md
→ Lock: Syncfusion theme, hex color system, 4pt DIP grid spacing, 1.25 type ratio
→ Select: Material / Fluent / custom XAML theme
→ Output: Design tokens confirmed; locked before any code generation
↓
[Stage — Control Skill Extraction] Control Skill Extraction 🔴 BLOCKING PRE-REQUISITE — Before Code Generation
→ Validate: ALL controls in control-mapping.json have validation='✓ VERIFIED' (score > 10)
→ For each control: Read skill file → Extract namespace, NuGet package, properties, events
→ Persist to: <project-root>/skill-extraction.json with validation_status="PASS"
→ Halt if: Skill file missing OR namespace/package/properties incomplete
→ Output: skill-extraction.json (pre-validated control metadata for Stage 5 code generation)
↓
[Stage 5B-1] Type Safety Enforcement 🔒 CRITICAL — runs BEFORE XAML generation
→ Validate Background → must be Brush type (SolidColorBrush, LinearGradientBrush, etc.)
→ Validate Margin → must be "double,double,double,double"
→ Validate FontSize → must be double > 0
→ Validate Width/Height → must be double > 0 or Auto
→ Validate Colors → must be #AARRGGBB or named color
→ Auto-fix: Replace invalid values with safe defaults
↓
[Stage 5B-2] Resource Validation 🔒 CRITICAL — runs BEFORE XAML generation
→ Scan all {StaticResource X} and {DynamicResource X} in XAML
→ Verify each key X exists in merged ResourceDictionary
→ Auto-inject missing keys with fallback values (e.g., SolidColorBrush #FF000000)
→ Check for duplicate x:Key values
↓
[Stage 5] Safe Code Generation 🔒 COMPLETE IMPLEMENTATION — UI + BACKEND
**Prerequisite:** skill-extraction.json exists with validation_status="PASS" (from Stage — Control Skill Extraction)
**Data source:** All namespaces/properties/events/packages from skill-extraction.json (never guessed)
**Pre-Generation Analysis (Mandatory):**
→ Read: references/stage-5-code-generation.md
→ Read control-mapping.json FIRST → identify all Syncfusion controls, events, commands
→ Read corresponding Syncfusion skill file → extract required properties & behaviors
→ Map XAML controls ↔ control-mapping.json ↔ skill directives for alignment
**Code Generation Principles (Strict Adherence):**
→ Generate ONLY methods, properties, events explicitly required by mapped controls
→ No generic boilerplate, utility methods, or unused stub code
→ Preserve existing codebase structure; avoid overwriting unrelated members
→ Tight alignment: every control + event + binding traces back to skill directive
**UI Generation (Complete Implementation):**
→ XAML: all Syncfusion namespaces, all mapped controls, all event bindings per skill
→ .xaml.cs: full event handler implementations, DataContext binding, all using statements
→ ViewModel: ALL bound properties (INotifyPropertyChanged), ALL ICommand bindings (RelayCommand)
**Backend Generation (Skill-Driven):**
→ Service classes: implement only business logic declared in control map + skill file
→ Repository + in-memory data: only if skill directives require data access
→ Navigation: open/close windows per skill success/failure paths
→ Validation: required fields + format checks per skill specification
→ Error propagation: surface errors from service → ViewModel → XAML display
**Functional Completeness & Safety:**
→ Every control must be fully wired to backend logic (no dead buttons or stub properties)
→ Output: complete, compilable, tested code — zero missing implementations
→ Constraints: no overwritten code, no unused members, minimal-but-full functionality
↓
[Stage 6] NuGet Dependency Management
→ Read: references/stage-6-dependencies.md
→ Detect required Syncfusion WPF + theme NuGet packages
→ Verify all XAML Syncfusion namespaces have corresponding packages
→ Output: dotnet add command(s) or auto-install
↓
[Stage 7] XAML Dry-Run Validation
→ Read: references/stage-7-validation.md + assets/validation-rules.md
→ Simulate XamlReader.Parse() on generated XAML
→ Auto-fix: invalid tags, missing namespaces, type mismatches
→ Loop until parse succeeds (max 5 iterations)
→ Abort on: circular reference, unsupported control type, licensing error
→ Output: PASS ✓ or FAIL ✗
↓
[Stage 8] Code Insertion
→ Insert all validated files (UI + backend) into project
→ Update project references, verify build
→ STOP on errors; report all inserted file paths on success
↓
✓ Complete
Stage Gate Summary
| Stage |
Interaction |
Behavior |
| 1–2 |
Auto-detect |
Auto-flow |
| 2A |
Framework check |
⛔ BLOCK on mismatch |
| 3 |
Control + backend action confirmation |
⭐ User gate |
| 4 |
Theming confirmation |
⭐ User gate |
| 5A |
Skill extraction + validation |
⛔ BLOCK if file missing or extraction fails |
| 5B-1–5B-2 |
Property + resource validation |
Auto-fix |
| 5 |
UI + backend code generation + skill alignment |
Auto-flow (only if Stage — Control Skill Extraction passed) |
| 6 |
Dependency validation gate |
⛔ BLOCK if skill-extraction.json missing |
| 6–6A |
Dependency + binding + service validation |
Auto-fix / Fail gate |
| 7 |
XAML dry-run validation |
Auto-fix loop |
| 8 |
Code insertion + build verification |
Auto-flow |
Agent Instructions
- Validate scope: Confirm request is for a WPF screen. Generate both UI and backend together — never UI alone.
- Stage — Control Skill Extraction is mandatory: Before ANY code generation, execute Stage — Control Skill Extraction (Control Skill Extraction). Halt if skill-extraction.json cannot be created or validated.
- Read control-mapping.json before Stage 5: Identify which controls appear, which events fire, and which backend actions are implied. Generate only what those controls need.
- Follow stage order strictly: Never skip or reorder stages. Stage — Control Skill Extraction must complete before Stage 5 (code generation).
- Load references on-demand: Read each stage's
.md file immediately before executing that stage.
- Stateless execution: Read all prior decisions from conversation context at each stage start.
- License key handling:
- Check for
SYNCFUSION_LICENSE_KEY in appsettings.json or environment
- If missing, prompt: "Get a free Community License at https://www.syncfusion.com/account/manage-trials"
- If provided, inject into
appsettings.json + call registerLicense() in app init
- If skipped, warn that a watermark will appear
Code Generation Rules (Mandatory)
⛔ Stage — Control Skill Extraction Prerequisite (CRITICAL)
- Before ANY code generation in Stage 5: Execute Stage — Control Skill Extraction
- Confirm
skill-extraction.json exists with validation_status: "PASS"
- All code generation must use data from
skill-extraction.json (namespaces, properties, events, packages)
- ❌ Never guess or assume APIs; ❌ Never infer package names
- ✅ All control metadata must be pre-extracted and verified
Control-Mapping-Driven Generation
- Before generating any code, read
control-mapping.json to identify:
- Every Syncfusion control required by the screen
- The associated skill reference file for each control
- The backend action (service method) mapped to each interactive control
- Generate only the methods, properties, commands, and events that are directly required by the mapped controls in XAML
- Do not add unrelated utility methods, extra services, or placeholder code not tied to a mapped control
Minimal-but-Complete Rule
Every generated file must be:
- Context-aware: driven by the specific skill and its control map, not a generic template
- Feature-complete: all controls in XAML are fully wired to logic (no dead buttons or unbound fields)
- Minimal: no boilerplate beyond what the mapped controls require
Screen Completeness Checklist
Before finalizing Stage 5 output, verify each screen satisfies:
| Requirement |
Example (Login Screen) |
| Input handling |
Email → SfTextInputLayout, Password → PasswordBox bound to ViewModel properties |
| Client-side validation |
Required field check, email regex, password min-length |
| Event handling |
Login ButtonAdv → LoginCommand.Execute → AuthService.ValidateCredentials |
| Backend logic |
AuthService.ValidateCredentials(email, password) returns success/failure |
| Navigation on success |
Opens DashboardWindow, closes LoginWindow |
| Error display |
Failure message shown via MessageBox or inline SfTextInputLayout error hint |
| Server-side validation |
AuthService rejects empty or malformed inputs independently of UI |
Boundary Rules (Critical)
| Rule |
Detail |
| UI + backend together |
Always generate both layers as one complete feature; never UI-only |
| Syncfusion controls only |
Use only Syncfusion WPF controls; never native MS controls (TextBox → SfTextInputLayout, Button → ButtonAdv, ComboBox → ComboBoxAdv, DataGrid → SfDataGrid, MessageBox → MessageBox, ProgressBar → SfLinearProgressBar, TreeView → SfTreeView, TabControl → SfTabControl, Calendar → CalendarEdit, DatePicker → SfDatePicker, TimePicker → SfTimePicker) |
| Skill file + control-mapping.json first |
Mandatory pre-generation: Read the Syncfusion skill file to extract required properties, behaviors, and constraints BEFORE any code generation in Stage 5. Cross-reference with control-mapping.json to ensure all controls, events, and backend actions align with skill directives. |
| Dependency rule: Skill files ONLY |
Before adding ANY NuGet package: (1) Read skill file, (2) Extract exact package name, (3) Use latest stable version, (4) Never assume/infer names. Only packages documented in skill files are permitted. Reject all others. |
| Mock data only |
Use in-memory repositories with sample data; no live DB or real API calls |
| No secrets |
Only SYNCFUSION_LICENSE_KEY when user explicitly provides it |
| Minimal-but-complete |
Generate exactly what the mapped controls need — no extra boilerplate |
| Compilation guaranteed |
Stage 6A must pass ALL checks (UI + backend) before any file is inserted |
| Framework purity |
Never mix WPF and WinUI controls or namespaces in same project |
DO ✅ / DON'T ❌ Guidelines
DO:
- ✅ Read the Syncfusion skill file FIRST to identify required properties, behaviors, and constraints
- ✅ Read
control-mapping.json SECOND to identify mapped controls, events, and backend actions
- ✅ Cross-reference skill file + control-mapping.json + XAML for tight alignment before any code generation
- ✅ Generate both UI and backend in Stage 5 as a single cohesive output
- ✅ Implement full event handler logic (login → validate → navigate), never stubs
- ✅ Wire every control in XAML to a ViewModel property, command, or event handler
- ✅ Use
MessageBox for dialogs, SfTextInputLayout for text inputs, ButtonAdv for buttons
- ✅ Use
SfDataGrid for all tabular data; never native DataGrid
- ✅ Lock design tokens in Stage 4 before generating any code in Stage 5
- ✅ Run the BM25
controls_search.cjs script in Stage 3
- ✅ Apply
AutomationProperties for all interactive controls
- ✅ Use
SfSkinManager for theme application
- ✅ Use relative layouts (Grid/StackPanel); never hardcode widths for responsive areas
DON'T:
- ❌ Generate code without reading the Syncfusion skill file first
- ❌ Skip reading both skill file AND
control-mapping.json before Stage 5
- ❌ Generate UI without the corresponding backend service and navigation logic
- ❌ Use native MS controls (
TextBox, Button, ComboBox, DataGrid, MessageBox, etc.)
- ❌ Generate code not directly required by mapped controls or skill directives (no unused helpers or empty stubs)
- ❌ Skip Stage 2A framework guard
- ❌ Generate XAML before Stage — Control Skill Extraction/5B validation passes
- ❌ Insert code before Stage 6A compilation gate passes
- ❌ Use
dynamic types without explicit justification
- ❌ Hardcode secrets in XAML or code-behind
Error Handling & Validation
Per-stage recovery:
- Retry once with same approach
- If retry fails → apply workaround or skip to next stage
- Notify user with error message
- Offer: "Would you like to go back to Stage 3 and choose a different layout?"
- Reference
references/Build.md for common errors
Compilation fail gate (Stage 6A):
- Missing event handler → HALT, regenerate Stage 5
- Missing binding property → HALT, regenerate Stage 5
- Missing service method called from ViewModel → HALT, regenerate Stage 5
- Missing
using statement → HALT, regenerate Stage 5
XAML parse loop (Stage 7):
- Max 5 auto-fix iterations
- Abort on: circular reference, unsupported control, licensing error
⛔ MANDATORY ERROR HANDLING PROTOCOL
If ANY build error or validation failure occurs:
Issue 1 & 3: Theme / Resource Errors
Errors: MC3072: Property 'BorderBrush' does not exist... or ResourceDictionary.DeferrableContent exception
- ✅ Fix: Stage 4 + Stage 7
- ✅ Apply Syncfusion theme ONLY via
SfSkinManager.SetTheme(this, new Theme("<LockedThemeName>")) in Window constructor
- ✅ Set
SfSkinManager.ApplyStylesOnApplication = true in App.xaml.cs OnStartup()
- ❌ NEVER merge Syncfusion theme ResourceDictionaries manually into
Application.Resources
- ✅ Custom resources ONLY:
Themes/Colors.xaml, Themes/Spacing.xaml, Themes/Typography.xaml
Issue 2: Missing Syncfusion Control
Error: 'SfTextInputLayout' does not exist in namespace...
- ✅ Fix: Stage 6 (Dependencies)
- ✅ Read
control-mapping.json → identify mapped control
- ✅ Read skill file (
syncfusion-wpf-[control]/SKILL.md) → extract exact NuGet package name
- ✅ Install package: latest stable version matching Stage 2 version
- ❌ NEVER assume or infer package names
Critical Rule: ALWAYS Read Skill Files First
If build fails OR control error occurs:
- ✅ Refer back to control's skill file FIRST
- ✅ Verify: API names, namespace declarations, NuGet package version
- ❌ DO NOT fallback automatically to Microsoft/WPF default controls (e.g.,
TextBox, ComboBox)
- ⛔ HALT if skill file missing or ambiguous — no silent corrections
- ✅ Retry build with skill-verified changes before next stage
Resource Loading Strategy (Mandatory)
Load files on-demand only — never preload all references.
| When |
Load |
| Before Stage 1 |
references/stage-1-intent-analysis.md |
| Before Stage 2 |
references/stage-2-project-detection.md |
| Before Stage 3 |
references/stage-3-layout-analysis.md |
| Before Stage 4 |
references/stage-4-theming-and-design-system.md |
| Before Stage — Control Skill Extraction |
control-mapping.json (validate ALL controls are ✓ VERIFIED)For each control: read <skills-root>/syncfusion-wpf-<control>/references/getting-started.md |
| After Stage — Control Skill Extraction |
✅ Confirm skill-extraction.json exists with validation_status: "PASS" before proceeding |
| Before Stage 5 |
references/stage-5-code-generation.md + skill-extraction.json (pre-extracted data source) |
| Before Stage 6 |
references/stage-6-dependencies.md + verify skill-extraction.json present |
| Before Stage 7 |
references/stage-7-validation.md + assets/validation-rules.md |
| Before Stage 8 |
references/wpf-dotnet-standards.md |
| On error |
references/Build.md |
Initial load: SKILL.md only. Full spec available on-demand.
Critical: Stage — Control Skill Extraction must complete successfully (producing skill-extraction.json) before Stage 5 code generation can begin. This is NOT optional.
Code Generation Standards
Accessibility (WCAG 2.1 AA)
AutomationProperties.Name and AutomationProperties.HelpText on all Syncfusion controls
- Keyboard navigation: correct tab order, focus management
- Color contrast ≥ 4.5:1; visible focus indicators on
SfButton and SfTextInputLayout
Responsive & DPI
- DPI-aware sizing using logical (device-independent) units
- Grid/StackPanel layouts; no fixed pixel widths for fluid areas
- Touch targets ≥ 44×44 device-independent units
Security
- Input validation in ViewModel and service layer; no hardcoded secrets in XAML
- Secure binding and command patterns; no code injection vectors
Performance
SfDataGrid virtualization enabled for large datasets
- Lazy loading for heavy resources; efficient
ObservableCollection binding
C# Quality
- Full type coverage (no unexplained
dynamic)
INotifyPropertyChanged with correct property-change notifications
- XML doc comments on all public service interfaces and models
RelayCommand pattern for all ICommand bindings
Supported Use Cases
| Request Type |
Key Syncfusion Controls |
Backend Generated |
| Login form |
SfTextInputLayout, ButtonAdv, SfCheckBox, MessageBox |
AuthService, LoginViewModel |
| Registration wizard |
SfTextInputLayout, ComboBoxAdv, ButtonAdv |
UserRegistrationService, step validators |
| Customer data table |
SfDataGrid (sort, filter, paginate) |
CustomerService, ICustomerRepository |
| Dashboard |
SfChart, SfDataGrid, SfTabControl, SfLinearProgressBar |
Aggregation services, summary DTOs |
| Kanban board |
SfKanban with swimlanes |
TaskService, status-transition logic |
| Data analysis tool |
SfChart, SfDataGrid, SfDatePicker |
Filter/query service, export logic |
Troubleshooting
| Issue |
Solution |
| Project type not detected |
Ensure .csproj has correct WPF target framework entry |
| Syncfusion watermark appears |
Add license key during Stage 2 prompt |
| Build fails after insertion |
See references/Build.md |
| Control not rendering |
Verify xmlns namespace declarations match installed NuGet packages |
| XAML parse error loops |
Check Stage 7 abort conditions; report control type to user |
| Missing binding at runtime |
Re-run Stage 6A validation; ensure ViewModel DataContext is set |
| Service method not found |
Confirm Stage 5 backend generation included the service; re-run Stage 6A |
| Navigation not working |
Verify success handler in event method opens target Window and closes current |
Full guide: references/Build.md
Additional Resources
Quick Reference by Use Case
| Need |
Reference File |
| Understanding workflow |
This SKILL.md file |
| How Stage X works |
references/stage-X-*.md |
| Validation rules |
assets/validation-rules.md |
| Accessibility/security |
references/wpf-dotnet-standards.md |
Support
For issues or questions:
- Verify your project meets prerequisites (.NET 6+, Windows App SDK 1.3+)
- Ensure Syncfusion license is valid and registered
- Review generated code compliance report for warnings
1---2name: syncfusion-wpf-ui-builder3description: Generates production-ready WPF desktop applications powered by Syncfusion WPF Controls. Orchestrates a structured workflow that handles design thinking, control picking, code generation, and validation with built-in UI Automation accessibility and DPI-aware responsive design. Use when the user asks to create WPF controls, build UI windows, design desktop interfaces, or generate code for WPF applications.4---56# Syncfusion WPF UI Builder78## Overview910The **Syncfusion WPF UI Builder** skill is a desktop-only WPF control generator that orchestrates an AI agent through 8 stages to generate production-ready UI controls powered by Syncfusion.1112## What This Skill Does1314**✅ Generates (UI Layer):**15- WPF XAML using Syncfusion controls + C# code-behind with MVVM pattern16- UI Automation accessibility markup (WCAG 2.1 AA)17- DPI-aware responsive layouts18- Client-side input validation and event handling1920**✅ Generates (Backend Layer):**21- Service classes with business logic (e.g., `AuthService`, `CustomerService`)22- Repository interfaces and in-memory implementations23- Navigation / screen-transition logic24- Data models, DTOs, and ViewModel interfaces2526**❌ Does NOT Generate:**27- Real database schemas, ORM migrations, or SQL28- Live third-party API integrations29- Authentication infrastructure (OAuth, JWT issuing)30- Environment secrets beyond `SYNCFUSION_LICENSE_KEY`3132> **Full-feature rule:** Every generated screen must be end-to-end functional — UI wired to backend logic, validation active, and navigation working. Partial logic or stub-only output is not acceptable.3334---3536## Quick Start3738### Prerequisites391. WPF project targeting .NET Framework 4.6.2+ or .NET 8+402. Visual Studio 2022+ with WPF workload413. Syncfusion WPF library (auto-installed if missing):42 ```bash43 dotnet add package Syncfusion.SfGrid.WPF44 ```454. Node.js 14+ (required for Stage 3 BM25 control-mapping script)4647### Examples4849**Login Form**50```51User: "Create a login form with email, password, and remember me checkbox"52Output:53 ✓ Views/LoginForm/LoginForm.xaml — SfTextInputLayout + SfButton54 ✓ Views/LoginForm/LoginForm.xaml.cs — event handling, navigation on success55 ✓ ViewModels/LoginViewModel.cs — INotifyPropertyChanged, ICommand56 ✓ Services/AuthService.cs — credential validation logic57 ✓ Models/LoginModel.cs — email, password, rememberMe fields58```5960**Customer Data Table**61```62User: "Build a customer data table with sorting and filtering"63Output:64 ✓ Views/CustomerTable/CustomerTable.xaml — SfDataGrid with sort/filter65 ✓ ViewModels/CustomerTableViewModel.cs — ObservableCollection, filter logic66 ✓ Services/CustomerService.cs — data retrieval, search logic67 ✓ Models/CustomerModel.cs — typed model with sample data68```6970---7172## Reusable Workflow Instructions7374### Key Architecture7576| Property | Detail |77|----------|--------|78| Design | Stateless — conversation history is sole state store |79| Stages | 8 total (6 automated, 2 user-gated) |80| User gates | Stage 3 (control confirmation) + Stage 4 (theming) |81| Auto-healing | Stages 5A, 5B, 6A, 7 auto-fix errors before passing downstream |82| Hard block | Stage 2A blocks on WPF/WinUI framework mismatch |83| Code scope | Both UI and backend generated together as one complete feature |8485### Stage Execution Flow (Mandatory Order)8687```88User Request89 ↓90[Stage 1] Intent Analysis91 → Parse query, identify control type & features, resolve ambiguities92 → Identify backend requirements (services, validation, navigation) implied by the screen93 → Read: references/stage-1-intent-analysis.md94 → Output: Control type + modifiers + target directory + backend scope summary95 ↓96[Stage 2] Project Detection97 → Auto-detect framework, .NET version, theming, project structure98 → Detect existing service/repository patterns to match generated backend style99 → Read: references/stage-2-project-detection.md100 → Output: Project config + user confirmation (with override option)101 ↓102[Stage 2A] Framework Consistency Guard ⛔ FAIL-FAST103 → Enforce WPF namespace: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"104 → BLOCK if WPF/WinUI controls or namespaces are mixed105 → Output: Confirmed namespace declarations or halt with mismatch report106 ↓107[Stage 3] Layout Analysis & Control Mapping ⭐ USER GATE #1 + SCRIPT REQUIRED108 → Read: references/stage-3-layout-analysis.md109 → Read control-mapping.json to identify:110 • Relevant Syncfusion controls for each UI element111 • Associated skill reference files per control112 → Run BM25 script: node controls_search.cjs <project-root>/control-mapping.json113 (cd <project-root>\.apm\skills\syncfusion-wpf-ui-builder\scripts first)114 → Map backend actions to each control (e.g., ButtonAdv[Login] → AuthService.ValidateAsync)115 → Output: control-mapping.json + Syncfusion control map + backend action map + user confirmation116 ↓117[Stage 4] Theming & Design System ⭐ USER GATE #2118 → Read: references/stage-4-theming-and-design-system.md119 → Lock: Syncfusion theme, hex color system, 4pt DIP grid spacing, 1.25 type ratio120 → Select: Material / Fluent / custom XAML theme121 → Output: Design tokens confirmed; locked before any code generation122 ↓123[Stage — Control Skill Extraction] Control Skill Extraction 🔴 BLOCKING PRE-REQUISITE — Before Code Generation124 → Validate: ALL controls in control-mapping.json have validation='✓ VERIFIED' (score > 10)125 → For each control: Read skill file → Extract namespace, NuGet package, properties, events126 → Persist to: <project-root>/skill-extraction.json with validation_status="PASS"127 → Halt if: Skill file missing OR namespace/package/properties incomplete128 → Output: skill-extraction.json (pre-validated control metadata for Stage 5 code generation)129 ↓130[Stage 5B-1] Type Safety Enforcement 🔒 CRITICAL — runs BEFORE XAML generation131 → Validate Background → must be Brush type (SolidColorBrush, LinearGradientBrush, etc.)132 → Validate Margin → must be "double,double,double,double"133 → Validate FontSize → must be double > 0134 → Validate Width/Height → must be double > 0 or Auto135 → Validate Colors → must be #AARRGGBB or named color136 → Auto-fix: Replace invalid values with safe defaults137 ↓138[Stage 5B-2] Resource Validation 🔒 CRITICAL — runs BEFORE XAML generation139 → Scan all {StaticResource X} and {DynamicResource X} in XAML140 → Verify each key X exists in merged ResourceDictionary141 → Auto-inject missing keys with fallback values (e.g., SolidColorBrush #FF000000)142 → Check for duplicate x:Key values143 ↓144[Stage 5] Safe Code Generation 🔒 COMPLETE IMPLEMENTATION — UI + BACKEND145 **Prerequisite:** skill-extraction.json exists with validation_status="PASS" (from Stage — Control Skill Extraction)146 **Data source:** All namespaces/properties/events/packages from skill-extraction.json (never guessed)147 **Pre-Generation Analysis (Mandatory):**148 → Read: references/stage-5-code-generation.md149 → Read control-mapping.json FIRST → identify all Syncfusion controls, events, commands150 → Read corresponding Syncfusion skill file → extract required properties & behaviors151 → Map XAML controls ↔ control-mapping.json ↔ skill directives for alignment152153 **Code Generation Principles (Strict Adherence):**154 → Generate ONLY methods, properties, events explicitly required by mapped controls155 → No generic boilerplate, utility methods, or unused stub code156 → Preserve existing codebase structure; avoid overwriting unrelated members157 → Tight alignment: every control + event + binding traces back to skill directive158159 **UI Generation (Complete Implementation):**160 → XAML: all Syncfusion namespaces, all mapped controls, all event bindings per skill161 → .xaml.cs: full event handler implementations, DataContext binding, all using statements162 → ViewModel: ALL bound properties (INotifyPropertyChanged), ALL ICommand bindings (RelayCommand)163164 **Backend Generation (Skill-Driven):**165 → Service classes: implement only business logic declared in control map + skill file166 → Repository + in-memory data: only if skill directives require data access167 → Navigation: open/close windows per skill success/failure paths168 → Validation: required fields + format checks per skill specification169 → Error propagation: surface errors from service → ViewModel → XAML display170171 **Functional Completeness & Safety:**172 → Every control must be fully wired to backend logic (no dead buttons or stub properties)173 → Output: complete, compilable, tested code — zero missing implementations174 → Constraints: no overwritten code, no unused members, minimal-but-full functionality175 ↓176[Stage 6] NuGet Dependency Management177 → Read: references/stage-6-dependencies.md178 → Detect required Syncfusion WPF + theme NuGet packages179 → Verify all XAML Syncfusion namespaces have corresponding packages180 → Output: dotnet add command(s) or auto-install181 ↓182[Stage 7] XAML Dry-Run Validation183 → Read: references/stage-7-validation.md + assets/validation-rules.md184 → Simulate XamlReader.Parse() on generated XAML185 → Auto-fix: invalid tags, missing namespaces, type mismatches186 → Loop until parse succeeds (max 5 iterations)187 → Abort on: circular reference, unsupported control type, licensing error188 → Output: PASS ✓ or FAIL ✗189 ↓190[Stage 8] Code Insertion191 → Insert all validated files (UI + backend) into project192 → Update project references, verify build193 → STOP on errors; report all inserted file paths on success194 ↓195✓ Complete196```197198### Stage Gate Summary199200| Stage | Interaction | Behavior |201|-------|-------------|----------|202| 1–2 | Auto-detect | Auto-flow |203| 2A | Framework check | ⛔ BLOCK on mismatch |204| 3 | Control + backend action confirmation | ⭐ User gate |205| 4 | Theming confirmation | ⭐ User gate |206| **5A** | **Skill extraction + validation** | **⛔ BLOCK if file missing or extraction fails** |207| 5B-1–5B-2 | Property + resource validation | Auto-fix |208| 5 | UI + backend code generation + skill alignment | Auto-flow (only if Stage — Control Skill Extraction passed) |209| 6 | Dependency validation gate | ⛔ BLOCK if skill-extraction.json missing |210| 6–6A | Dependency + binding + service validation | Auto-fix / Fail gate |211| 7 | XAML dry-run validation | Auto-fix loop |212| 8 | Code insertion + build verification | Auto-flow |213214---215216## Agent Instructions2172181. **Validate scope**: Confirm request is for a WPF screen. Generate both UI and backend together — never UI alone.2192. **Stage — Control Skill Extraction is mandatory**: Before ANY code generation, execute Stage — Control Skill Extraction (Control Skill Extraction). Halt if skill-extraction.json cannot be created or validated.2203. **Read control-mapping.json before Stage 5**: Identify which controls appear, which events fire, and which backend actions are implied. Generate only what those controls need.2214. **Follow stage order strictly**: Never skip or reorder stages. Stage — Control Skill Extraction must complete before Stage 5 (code generation).2225. **Load references on-demand**: Read each stage's `.md` file immediately before executing that stage.2236. **Stateless execution**: Read all prior decisions from conversation context at each stage start.2247. **License key handling**:225 - Check for `SYNCFUSION_LICENSE_KEY` in `appsettings.json` or environment226 - If missing, prompt: *"Get a free Community License at https://www.syncfusion.com/account/manage-trials"*227 - If provided, inject into `appsettings.json` + call `registerLicense()` in app init228 - If skipped, warn that a watermark will appear229230---231232## Code Generation Rules (Mandatory)233234### ⛔ Stage — Control Skill Extraction Prerequisite (CRITICAL)235- **Before ANY code generation in Stage 5**: Execute Stage — Control Skill Extraction236- Confirm `skill-extraction.json` exists with `validation_status: "PASS"`237- **All code generation must use data from `skill-extraction.json`** (namespaces, properties, events, packages)238- ❌ Never guess or assume APIs; ❌ Never infer package names239- ✅ All control metadata must be pre-extracted and verified240241### Control-Mapping-Driven Generation242- **Before generating any code**, read `control-mapping.json` to identify:243 - Every Syncfusion control required by the screen244 - The associated skill reference file for each control245 - The backend action (service method) mapped to each interactive control246- Generate **only** the methods, properties, commands, and events that are directly required by the mapped controls in XAML247- Do not add unrelated utility methods, extra services, or placeholder code not tied to a mapped control248249### Minimal-but-Complete Rule250Every generated file must be:251- **Context-aware**: driven by the specific skill and its control map, not a generic template252- **Feature-complete**: all controls in XAML are fully wired to logic (no dead buttons or unbound fields)253- **Minimal**: no boilerplate beyond what the mapped controls require254255### Screen Completeness Checklist256Before finalizing Stage 5 output, verify each screen satisfies:257258| Requirement | Example (Login Screen) |259|-------------|------------------------|260| Input handling | Email → `SfTextInputLayout`, Password → `PasswordBox` bound to ViewModel properties |261| Client-side validation | Required field check, email regex, password min-length |262| Event handling | Login `ButtonAdv` → `LoginCommand.Execute` → `AuthService.ValidateCredentials` |263| Backend logic | `AuthService.ValidateCredentials(email, password)` returns success/failure |264| Navigation on success | Opens `DashboardWindow`, closes `LoginWindow` |265| Error display | Failure message shown via `MessageBox` or inline `SfTextInputLayout` error hint |266| Server-side validation | `AuthService` rejects empty or malformed inputs independently of UI |267268---269270## Boundary Rules (Critical)271272| Rule | Detail |273|------|--------|274| UI + backend together | Always generate both layers as one complete feature; never UI-only |275| Syncfusion controls only | Use only Syncfusion WPF controls; never native MS controls (TextBox → `SfTextInputLayout`, Button → `ButtonAdv`, ComboBox → `ComboBoxAdv`, DataGrid → `SfDataGrid`, MessageBox → `MessageBox`, ProgressBar → `SfLinearProgressBar`, TreeView → `SfTreeView`, TabControl → `SfTabControl`, Calendar → `CalendarEdit`, DatePicker → `SfDatePicker`, TimePicker → `SfTimePicker`) |276| Skill file + control-mapping.json first | **Mandatory pre-generation:** Read the Syncfusion skill file to extract required properties, behaviors, and constraints BEFORE any code generation in Stage 5. Cross-reference with control-mapping.json to ensure all controls, events, and backend actions align with skill directives. |277| Dependency rule: Skill files ONLY | **Before adding ANY NuGet package:** (1) Read skill file, (2) Extract exact package name, (3) Use latest stable version, (4) Never assume/infer names. Only packages documented in skill files are permitted. Reject all others. |278| Mock data only | Use in-memory repositories with sample data; no live DB or real API calls |279| No secrets | Only `SYNCFUSION_LICENSE_KEY` when user explicitly provides it |280| Minimal-but-complete | Generate exactly what the mapped controls need — no extra boilerplate |281| Compilation guaranteed | Stage 6A must pass ALL checks (UI + backend) before any file is inserted |282| Framework purity | Never mix WPF and WinUI controls or namespaces in same project |283284---285286## DO ✅ / DON'T ❌ Guidelines287288**DO:**289- ✅ Read the Syncfusion skill file FIRST to identify required properties, behaviors, and constraints290- ✅ Read `control-mapping.json` SECOND to identify mapped controls, events, and backend actions291- ✅ Cross-reference skill file + control-mapping.json + XAML for tight alignment before any code generation292- ✅ Generate both UI and backend in Stage 5 as a single cohesive output293- ✅ Implement full event handler logic (login → validate → navigate), never stubs294- ✅ Wire every control in XAML to a ViewModel property, command, or event handler295- ✅ Use `MessageBox` for dialogs, `SfTextInputLayout` for text inputs, `ButtonAdv` for buttons296- ✅ Use `SfDataGrid` for all tabular data; never native `DataGrid`297- ✅ Lock design tokens in Stage 4 before generating any code in Stage 5298- ✅ Run the BM25 `controls_search.cjs` script in Stage 3299- ✅ Apply `AutomationProperties` for all interactive controls300- ✅ Use `SfSkinManager` for theme application301- ✅ Use relative layouts (Grid/StackPanel); never hardcode widths for responsive areas302303**DON'T:**304- ❌ Generate code without reading the Syncfusion skill file first305- ❌ Skip reading both skill file AND `control-mapping.json` before Stage 5306- ❌ Generate UI without the corresponding backend service and navigation logic307- ❌ Use native MS controls (`TextBox`, `Button`, `ComboBox`, `DataGrid`, `MessageBox`, etc.)308- ❌ Generate code not directly required by mapped controls or skill directives (no unused helpers or empty stubs)309- ❌ Skip Stage 2A framework guard310- ❌ Generate XAML before Stage — Control Skill Extraction/5B validation passes311- ❌ Insert code before Stage 6A compilation gate passes312- ❌ Use `dynamic` types without explicit justification313- ❌ Hardcode secrets in XAML or code-behind314315---316317## Error Handling & Validation318319**Per-stage recovery:**3201. Retry once with same approach3212. If retry fails → apply workaround or skip to next stage3223. Notify user with error message3234. Offer: *"Would you like to go back to Stage 3 and choose a different layout?"*3245. Reference `references/Build.md` for common errors325326**Compilation fail gate (Stage 6A):**327- Missing event handler → HALT, regenerate Stage 5328- Missing binding property → HALT, regenerate Stage 5329- Missing service method called from ViewModel → HALT, regenerate Stage 5330- Missing `using` statement → HALT, regenerate Stage 5331332**XAML parse loop (Stage 7):**333- Max 5 auto-fix iterations334- Abort on: circular reference, unsupported control, licensing error335336---337338## ⛔ MANDATORY ERROR HANDLING PROTOCOL339340**If ANY build error or validation failure occurs:**341342### Issue 1 & 3: Theme / Resource Errors343**Errors:** `MC3072: Property 'BorderBrush' does not exist...` or `ResourceDictionary.DeferrableContent exception`344- ✅ **Fix:** Stage 4 + Stage 7345- ✅ Apply Syncfusion theme ONLY via `SfSkinManager.SetTheme(this, new Theme("<LockedThemeName>"))` in Window constructor346- ✅ Set `SfSkinManager.ApplyStylesOnApplication = true` in `App.xaml.cs` `OnStartup()`347- ❌ NEVER merge Syncfusion theme ResourceDictionaries manually into `Application.Resources`348- ✅ Custom resources ONLY: `Themes/Colors.xaml`, `Themes/Spacing.xaml`, `Themes/Typography.xaml`349350### Issue 2: Missing Syncfusion Control351**Error:** `'SfTextInputLayout' does not exist in namespace...`352- ✅ **Fix:** Stage 6 (Dependencies)353- ✅ Read `control-mapping.json` → identify mapped control354- ✅ Read skill file (`syncfusion-wpf-[control]/SKILL.md`) → extract exact NuGet package name355- ✅ Install package: latest stable version matching Stage 2 version356- ❌ NEVER assume or infer package names357358### Critical Rule: ALWAYS Read Skill Files First359**If build fails OR control error occurs:**3601. ✅ Refer back to control's skill file FIRST3612. ✅ Verify: API names, namespace declarations, NuGet package version3623. ❌ DO NOT fallback automatically to Microsoft/WPF default controls (e.g., `TextBox`, `ComboBox`)3634. ⛔ HALT if skill file missing or ambiguous — no silent corrections3645. ✅ Retry build with skill-verified changes before next stage365366---367368## Resource Loading Strategy (Mandatory)369370Load files **on-demand only** — never preload all references.371372| When | Load |373|------|------|374| Before Stage 1 | `references/stage-1-intent-analysis.md` |375| Before Stage 2 | `references/stage-2-project-detection.md` |376| Before Stage 3 | `references/stage-3-layout-analysis.md` |377| Before Stage 4 | `references/stage-4-theming-and-design-system.md` |378| **Before Stage — Control Skill Extraction** | **`control-mapping.json` (validate ALL controls are ✓ VERIFIED)**<br/>**For each control: read `<skills-root>/syncfusion-wpf-<control>/references/getting-started.md`** |379| After Stage — Control Skill Extraction | ✅ Confirm `skill-extraction.json` exists with `validation_status: "PASS"` before proceeding |380| Before Stage 5 | `references/stage-5-code-generation.md` + `skill-extraction.json` (pre-extracted data source) |381| Before Stage 6 | `references/stage-6-dependencies.md` + verify `skill-extraction.json` present |382| Before Stage 7 | `references/stage-7-validation.md` + `assets/validation-rules.md` |383| Before Stage 8 | `references/wpf-dotnet-standards.md` |384| On error | `references/Build.md` |385386**Initial load:** SKILL.md only. Full spec available on-demand.387388**Critical:** Stage — Control Skill Extraction must complete successfully (producing `skill-extraction.json`) before Stage 5 code generation can begin. This is NOT optional.389390---391392## Code Generation Standards393394### Accessibility (WCAG 2.1 AA)395- `AutomationProperties.Name` and `AutomationProperties.HelpText` on all Syncfusion controls396- Keyboard navigation: correct tab order, focus management397- Color contrast ≥ 4.5:1; visible focus indicators on `SfButton` and `SfTextInputLayout`398399### Responsive & DPI400- DPI-aware sizing using logical (device-independent) units401- Grid/StackPanel layouts; no fixed pixel widths for fluid areas402- Touch targets ≥ 44×44 device-independent units403404### Security405- Input validation in ViewModel and service layer; no hardcoded secrets in XAML406- Secure binding and command patterns; no code injection vectors407408### Performance409- `SfDataGrid` virtualization enabled for large datasets410- Lazy loading for heavy resources; efficient `ObservableCollection` binding411412### C# Quality413- Full type coverage (no unexplained `dynamic`)414- `INotifyPropertyChanged` with correct property-change notifications415- XML doc comments on all public service interfaces and models416- `RelayCommand` pattern for all ICommand bindings417418---419420## Supported Use Cases421422| Request Type | Key Syncfusion Controls | Backend Generated |423|---|---|---|424| Login form | `SfTextInputLayout`, `ButtonAdv`, `SfCheckBox`, `MessageBox` | `AuthService`, `LoginViewModel` |425| Registration wizard | `SfTextInputLayout`, `ComboBoxAdv`, `ButtonAdv` | `UserRegistrationService`, step validators |426| Customer data table | `SfDataGrid` (sort, filter, paginate) | `CustomerService`, `ICustomerRepository` |427| Dashboard | `SfChart`, `SfDataGrid`, `SfTabControl`, `SfLinearProgressBar` | Aggregation services, summary DTOs |428| Kanban board | `SfKanban` with swimlanes | `TaskService`, status-transition logic |429| Data analysis tool | `SfChart`, `SfDataGrid`, `SfDatePicker` | Filter/query service, export logic |430431---432433## Troubleshooting434435| Issue | Solution |436|-------|----------|437| Project type not detected | Ensure `.csproj` has correct WPF target framework entry |438| Syncfusion watermark appears | Add license key during Stage 2 prompt |439| Build fails after insertion | See `references/Build.md` |440| Control not rendering | Verify `xmlns` namespace declarations match installed NuGet packages |441| XAML parse error loops | Check Stage 7 abort conditions; report control type to user |442| Missing binding at runtime | Re-run Stage 6A validation; ensure ViewModel DataContext is set |443| Service method not found | Confirm Stage 5 backend generation included the service; re-run Stage 6A |444| Navigation not working | Verify success handler in event method opens target Window and closes current |445446**Full guide:** `references/Build.md`447448## Additional Resources449450### Quick Reference by Use Case451452| Need | Reference File |453|------|-----------------|454| Understanding workflow | This SKILL.md file |455| How Stage X works | `references/stage-X-*.md` |456| Validation rules | `assets/validation-rules.md` |457| Accessibility/security | `references/wpf-dotnet-standards.md` |458459## Support460461For issues or questions:4621. Verify your project meets prerequisites (.NET 6+, Windows App SDK 1.3+)4632. Ensure Syncfusion license is valid and registered4643. Review generated code compliance report for warnings