# Getting Started | WPF Controls | DevExpress Documentation

This tutorial provides step-by-step instructions on how to create a simple application with the [AccordionControl](/WPF/DevExpress.Xpf.Accordion.AccordionControl).

## Add a Data Model

The **AccordionControl** can be bound to any object that implements the [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable) interface or its descendant (for example, IList, ICollection).

The code sample below demonstrates a simple data model that is used in this tutorial:

- C#
- VB.NET

<section id="tabpanel_IPsVyhfUd8_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code data-code-links="{&quot;/ (System.Collections.Generic)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.collections.generic&quot;}" class="lang-csharp">using System.Collections.Generic;

namespace DxAccordionGettingStarted {
    public class Employee {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Position { get; set; }
        public string Department { get; set; }
        public override string ToString() {
            return Name;
        }
    }

    public static class Staff {
        public static List&lt;Employee&gt; GetStaff() {
            List&lt;Employee&gt; employees = new List&lt;Employee&gt;();
            employees.Add(new Employee() { ID = 1, Name = &quot;Gregory S. Price&quot;, Department = &quot;Management&quot;, Position = &quot;President&quot; });
            employees.Add(new Employee() { ID = 2, Name = &quot;Irma R. Marshall&quot;, Department = &quot;Marketing&quot;, Position = &quot;Vice President&quot; });
            employees.Add(new Employee() { ID = 3, Name = &quot;John C. Powell&quot;, Department = &quot;Operations&quot;, Position = &quot;Vice President&quot; });
            employees.Add(new Employee() { ID = 4, Name = &quot;Christian P. Laclair&quot;, Department = &quot;Production&quot;, Position = &quot;Vice President&quot; });
            employees.Add(new Employee() { ID = 5, Name = &quot;Karen J. Kelly&quot;, Department = &quot;Finance&quot;, Position = &quot;Vice President&quot; });

            employees.Add(new Employee() { ID = 6, Name = &quot;Brian C. Cowling&quot;, Department = &quot;Marketing&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 7, Name = &quot;Thomas C. Dawson&quot;, Department = &quot;Marketing&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 8, Name = &quot;Angel M. Wilson&quot;, Department = &quot;Marketing&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 9, Name = &quot;Bryan R. Henderson&quot;, Department = &quot;Marketing&quot;, Position = &quot;Manager&quot; });

            employees.Add(new Employee() { ID = 10, Name = &quot;Harold S. Brandes&quot;, Department = &quot;Operations&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 11, Name = &quot;Michael S. Blevins&quot;, Department = &quot;Operations&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 12, Name = &quot;Jan K. Sisk&quot;, Department = &quot;Operations&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 13, Name = &quot;Sidney L. Holder&quot;, Department = &quot;Operations&quot;, Position = &quot;Manager&quot; });

            employees.Add(new Employee() { ID = 14, Name = &quot;James L. Kelsey&quot;, Department = &quot;Production&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 15, Name = &quot;Howard M. Carpenter&quot;, Department = &quot;Production&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 16, Name = &quot;Jennifer T. Tapia&quot;, Department = &quot;Production&quot;, Position = &quot;Manager&quot; });

            employees.Add(new Employee() { ID = 17, Name = &quot;Judith P. Underhill&quot;, Department = &quot;Finance&quot;, Position = &quot;Manager&quot; });
            employees.Add(new Employee() { ID = 18, Name = &quot;Russell E. Belton&quot;, Department = &quot;Finance&quot;, Position = &quot;Manager&quot; });
            return employees;
        }
    }
}
</code></pre></section>
<section id="tabpanel_IPsVyhfUd8_tabid-vb" role="tabpanel" data-tab="tabid-vb" aria-hidden="true" hidden="hidden">
<pre><code data-code-links="{&quot;/ (System.Collections.Generic)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.collections.generic&quot;}" class="lang-vb">Imports System.Collections.Generic

Namespace DxAccordionGettingStarted

    Public Class Employee

        Public Property ID As Integer

        Public Property Name As String

        Public Property Position As String

        Public Property Department As String

        Public Overrides Function ToString() As String
            Return Name
        End Function
    End Class

    Public Module Staff

        Public Function GetStaff() As List(Of Employee)
            Dim employees As List(Of Employee) = New List(Of Employee)()
            employees.Add(New Employee() With {.ID = 1, .Name = &quot;Gregory S. Price&quot;, .Department = &quot;Management&quot;, .Position = &quot;President&quot;})
            employees.Add(New Employee() With {.ID = 2, .Name = &quot;Irma R. Marshall&quot;, .Department = &quot;Marketing&quot;, .Position = &quot;Vice President&quot;})
            employees.Add(New Employee() With {.ID = 3, .Name = &quot;John C. Powell&quot;, .Department = &quot;Operations&quot;, .Position = &quot;Vice President&quot;})
            employees.Add(New Employee() With {.ID = 4, .Name = &quot;Christian P. Laclair&quot;, .Department = &quot;Production&quot;, .Position = &quot;Vice President&quot;})
            employees.Add(New Employee() With {.ID = 5, .Name = &quot;Karen J. Kelly&quot;, .Department = &quot;Finance&quot;, .Position = &quot;Vice President&quot;})
            employees.Add(New Employee() With {.ID = 6, .Name = &quot;Brian C. Cowling&quot;, .Department = &quot;Marketing&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 7, .Name = &quot;Thomas C. Dawson&quot;, .Department = &quot;Marketing&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 8, .Name = &quot;Angel M. Wilson&quot;, .Department = &quot;Marketing&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 9, .Name = &quot;Bryan R. Henderson&quot;, .Department = &quot;Marketing&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 10, .Name = &quot;Harold S. Brandes&quot;, .Department = &quot;Operations&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 11, .Name = &quot;Michael S. Blevins&quot;, .Department = &quot;Operations&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 12, .Name = &quot;Jan K. Sisk&quot;, .Department = &quot;Operations&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 13, .Name = &quot;Sidney L. Holder&quot;, .Department = &quot;Operations&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 14, .Name = &quot;James L. Kelsey&quot;, .Department = &quot;Production&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 15, .Name = &quot;Howard M. Carpenter&quot;, .Department = &quot;Production&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 16, .Name = &quot;Jennifer T. Tapia&quot;, .Department = &quot;Production&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 17, .Name = &quot;Judith P. Underhill&quot;, .Department = &quot;Finance&quot;, .Position = &quot;Manager&quot;})
            employees.Add(New Employee() With {.ID = 18, .Name = &quot;Russell E. Belton&quot;, .Department = &quot;Finance&quot;, .Position = &quot;Manager&quot;})
            Return employees
        End Function
    End Module
End Namespace
</code></pre></section>

## Add a View Model

Create a view model that retrieves data from the data model:

- C#
- VB.NET

<section id="tabpanel_IPsVyhfUd8-1_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code data-code-links="{&quot;/ (System.Collections.Generic)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.collections.generic&quot;,&quot;/ (System.Collections.ObjectModel)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.collections.objectmodel&quot;,&quot;/ (System.Linq)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.linq&quot;}" class="lang-csharp">using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace DxAccordionGettingStarted {
    public class MainWindowViewModel {
        public MainWindowViewModel() {
            var employeeDepartments = Staff.GetStaff()
                .GroupBy(x =&gt; x.Department)
                .Select(x =&gt; new EmployeeDepartment(x.Key, x.ToArray()));
            EmployeeDepartments = new ObservableCollection&lt;EmployeeDepartment&gt;(employeeDepartments.ToArray());
        }
        public ObservableCollection&lt;EmployeeDepartment&gt; EmployeeDepartments { get; set; }
    }

    public class EmployeeDepartment {
        public string Name { get; set; }
        public ObservableCollection&lt;Employee&gt; Employees { get; set; }

        public EmployeeDepartment(string name, IEnumerable&lt;Employee&gt; employees) {
            Name = name;
            Employees = new ObservableCollection&lt;Employee&gt;(employees);
        }
        public override string ToString() {
            return Name;
        }
    }
}
</code></pre></section>
<section id="tabpanel_IPsVyhfUd8-1_tabid-vb" role="tabpanel" data-tab="tabid-vb" aria-hidden="true" hidden="hidden">
<pre><code data-code-links="{&quot;/ (System.Collections.Generic)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.collections.generic&quot;,&quot;/ (System.Collections.ObjectModel)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.collections.objectmodel&quot;,&quot;/ (System.Linq)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.linq&quot;}" class="lang-vb">Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Linq

Namespace DxAccordionGettingStarted

    Public Class MainWindowViewModel

        Public Sub New()
            Dim employeeDepartments = GetStaff().GroupBy(Function(x) x.Department).[Select](Function(x) New EmployeeDepartment(x.Key, x.ToArray()))
            Me.EmployeeDepartments = New ObservableCollection(Of EmployeeDepartment)(employeeDepartments.ToArray())
        End Sub

        Public Property EmployeeDepartments As ObservableCollection(Of EmployeeDepartment)
    End Class

    Public Class EmployeeDepartment

        Public Property Name As String

        Public Property Employees As ObservableCollection(Of Employee)

        Public Sub New(ByVal name As String, ByVal employees As IEnumerable(Of Employee))
            Me.Name = name
            Me.Employees = New ObservableCollection(Of Employee)(employees)
        End Sub

        Public Overrides Function ToString() As String
            Return Name
        End Function
    End Class
End Namespace
</code></pre></section>

Build the solution. Invoke the main window’s [Quick Actions](/WPF/18095/whats-installed/smart-tags) and define the window’s data context as shown in the image below:

![AccordionViewModel](/WPF/images/accordionviewmodel132063.png)

## Add the AccordionControl to a View

Drag the **AccordionControl** from the **DX.26.1: Navigation & Layout** Toolbox tab and drop it onto the main window.

Tip

If you add the DevExpress products via a NuGet feed instead of the [Unified Component Installer](/GeneralInformation/15615/installation/download-the-registered-version), the toolbox doesn’t contain DevExpress controls until you add the corresponding NuGet package.

Go to **Tools | NuGet Package Manager | Manage NuGet Packages for Solution** and add the **DevExpress.Wpf.Accordion** NuGet package.

Right-click the control and select **Layout | Reset All** to allow the AccordionControl to fill the entire window:

![AccordionVisualStudio](/WPF/images/accordionvisualstudio132057.png)

## Bind the AccordionControl to Data

Invoke the AccordionControl’s Quick Actions and define the **ItemsSource** field:

![AccordionItemSource](/WPF/images/accordionitemsource132058.png)

Define the **ChildrenPath** field that specifies the path to the property that contains an accordion item’s children:

![AccordionChildrenPath](/WPF/images/accordionchildrenpath132060.png)

Tip

Refer to the [Data Binding](/WPF/118635/controls-and-libraries/navigation-controls/accordion-control/data-binding) topic for details on different approaches to binding the AccordionControl to data.

The code sample below demonstrates the generated code:

- XAML

<section id="tabpanel_IPsVyhfUd8-2_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;Window  
   xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; 
   xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; 
   xmlns:dxa=&quot;http://schemas.devexpress.com/winfx/2008/xaml/accordion&quot; 
   xmlns:local=&quot;clr-namespace:DxAccordionGettingStarted&quot; 
   x:Class=&quot;DxAccordionGettingStarted.MainWindow&quot; 
   Title=&quot;MainWindow&quot; Height=&quot;350&quot; Width=&quot;525&quot;&gt;
    &lt;Window.DataContext&gt;
        &lt;local:MainWindowViewModel/&gt;
    &lt;/Window.DataContext&gt;
    &lt;Grid&gt;
        &lt;dxa:AccordionControl ItemsSource=&quot;{Binding EmployeeDepartments}&quot; ChildrenPath=&quot;Employees&quot;/&gt;
    &lt;/Grid&gt;
&lt;/Window&gt;
</code></pre></section>

## Get the Result

Run the solution to see the result:

![AccordionResult](/WPF/images/accordionresult132053.png)