$npx -y skills add DevExpress/agent-skills --skill devexpress-wpf-accordionBuild WPF applications with the DevExpress Accordion Control (AccordionControl) — a hierarchical navigation control for compact app sidebars and category-based UIs. Use when adding AccordionControl to a WPF project; defining static items in XAML (AccordionItem with Header, Glyph,
| 1 | # DevExpress WPF Accordion Control |
| 2 | |
| 3 | `DevExpress.Xpf.Accordion.AccordionControl` is a hierarchical navigation control with an unlimited tree depth, multiple selection / expand modes, optional Office-style navigation-pane layout, built-in search, and Office Navigation Bar integration. It's the recommended replacement for the older `NavBarControl` in new projects — simpler API, more customization room, modern look. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when you need to: |
| 8 | |
| 9 | - Add a hierarchical navigation sidebar to a WPF app |
| 10 | - Define items statically in XAML, or bind to a ViewModel collection |
| 11 | - Switch between Default (expand/collapse tree) and Navigation Pane (top-level items as tabs) view modes |
| 12 | - Show items with glyphs, headers, custom content (editors, images) |
| 13 | - Add a search field for end users to filter items |
| 14 | - Collapse the panel into a compact strip with glyph-only items |
| 15 | - Decide between `AccordionControl`, `NavBarControl`, and `HamburgerMenu` for navigation |
| 16 | |
| 17 | ## Prerequisites & Installation |
| 18 | |
| 19 | ### NuGet Packages |
| 20 | |
| 21 | | Package | Purpose | |
| 22 | |---------|---------| |
| 23 | | `DevExpress.Wpf.Accordion` | Main package — `AccordionControl`, `AccordionItem` | |
| 24 | | `DevExpress.Wpf.Navigation` | Required when integrating with `OfficeNavigationBar` | |
| 25 | |
| 26 | `DevExpress.Wpf.Accordion` transitively brings `DevExpress.Wpf.Core`. |
| 27 | |
| 28 | ### .NET 8+ |
| 29 | |
| 30 | ```bash |
| 31 | dotnet add package DevExpress.Wpf.Accordion |
| 32 | ``` |
| 33 | |
| 34 | Add to `.csproj`: |
| 35 | |
| 36 | ```xml |
| 37 | <PropertyGroup> |
| 38 | <TargetFramework>net8.0-windows</TargetFramework> |
| 39 | <UseWPF>true</UseWPF> |
| 40 | </PropertyGroup> |
| 41 | ``` |
| 42 | |
| 43 | All DevExpress packages in a project must share the same version. |
| 44 | |
| 45 | ## Before You Start — Ask the Developer |
| 46 | |
| 47 | If the host agent has a structured question-asking tool available, use it to ask these questions one at a time with clear options — for example, Claude Code's `AskUserQuestion` tool or GitHub Copilot's `askQuestions` tool. If no such tool is available, ask the questions directly in the chat response before generating code. |
| 48 | |
| 49 | 1. **Target framework**: .NET 8+ or .NET Framework 4.x? |
| 50 | 2. **Items source**: static (defined in XAML) or dynamic (bound to a ViewModel collection)? |
| 51 | 3. **Data shape**: all items the same type with a children property → `ChildrenPath`; mixed item types → `ChildrenSelector`; rich templating per level → `HierarchicalDataTemplate`. See [data-binding.md](references/data-binding.md). |
| 52 | 4. **View mode**: `Default` (classic accordion) or `NavigationPane` (Outlook-style root tabs)? |
| 53 | 5. **Expand mode**: how many items can be open at once — `Multiple`, `MultipleOrNone`, `Single`, `SingleOrNone`? |
| 54 | 6. **Search**: should end users search the items? (`ShowSearchControl`) |
| 55 | 7. **Collapse**: should the panel collapse into a compact strip? (`IsCollapseButtonVisible`) |
| 56 | 8. **Why Accordion vs alternatives**: see [when-to-use.md](references/when-to-use.md) for the comparison with `NavBarControl` and `HamburgerMenu`. |
| 57 | |
| 58 | ## Component Overview |
| 59 | |
| 60 | ### XAML Namespace |
| 61 | |
| 62 | ```xml |
| 63 | xmlns:dxa="http://schemas.devexpress.com/winfx/2008/xaml/accordion" |
| 64 | ``` |
| 65 | |
| 66 | ### Element Hierarchy |
| 67 | |
| 68 | ``` |
| 69 | AccordionControl |
| 70 | ├── (ItemsSource OR Items) |
| 71 | └── AccordionItem (root) |
| 72 | ├── Header — caption or any UIElement |
| 73 | ├── Glyph — icon |
| 74 | └── Items — child AccordionItem objects (or any nested UIElement) |
| 75 | ``` |
| 76 | |
| 77 | `AccordionItem` plays two roles depending on context: |
| 78 | |
| 79 | - **Root item** — top-level entry in the accordion |
| 80 | - **Subitem** — nested under a parent `AccordionItem` |
| 81 | |
| 82 | The same class for both — the position in the tree (and `AccordionItem.ItemLevel`, where `0` is root) tells the runtime which. |
| 83 | |
| 84 | ### Two Population Approaches |
| 85 | |
| 86 | 1. **Static items in XAML** — define `AccordionItem` elements directly under `AccordionControl`. Good for fixed navigation menus. |
| 87 | 2. **Data binding** — set `ItemsSource` to a collection. Good when the menu reflects a ViewModel, runtime data, or runtime additions |