How to: Create a Simple Application with the AccordionControl

  • 6 minutes to read

This example demonstrates how to create a simple application with the AccordionControl.

See the Getting Started tutorial to learn more.

The image below shows the result:

AccordionResult

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace DxAccordionGettingStarted {
    public class MainWindowViewModel {
        public MainWindowViewModel() {
            var employeeDepartments = Stuff.GetStuff()
                .GroupBy(x => x.Department)
                .Select(x => new EmployeeDepartment(x.Key, x.ToArray()));
            EmployeeDepartments = new ObservableCollection<EmployeeDepartment>(employeeDepartments.ToArray());
        }
        public ObservableCollection<EmployeeDepartment> EmployeeDepartments { get; set; }
    }

    public class EmployeeDepartment {
        public string Name { get; set; }
        public ObservableCollection<Employee> Employees { get; set; }

        public EmployeeDepartment(string name, IEnumerable<Employee> employees) {
            Name = name;
            Employees = new ObservableCollection<Employee>(employees);
        }
        public override string ToString() {
            return Name;
        }
    }
}