# Children Selector | WPF Controls | DevExpress Documentation

This topic describes how to bind the [AccordionControl](/WPF/DevExpress.Xpf.Accordion.AccordionControl) to data if your data source contains objects of different types.

The table below shows the required properties:

| Member | Description |
| --- | --- |
| [AccordionControl.ItemsSource](/WPF/DevExpress.Xpf.Accordion.AccordionControl.ItemsSource) | Specifies the path to a collection of accordion items. |
| [AccordionControl.ChildrenSelector](/WPF/DevExpress.Xpf.Accordion.AccordionControl.ChildrenSelector) | Allows choosing the item’s children based on custom logic. |

Complete the following steps to configure the binding:

1. Specify the [AccordionControl.ItemsSource](/WPF/DevExpress.Xpf.Accordion.AccordionControl.ItemsSource) property to bind the [AccordionControl](/WPF/DevExpress.Xpf.Accordion.AccordionControl) to data:

- XAML

<section id="tabpanel_c581ci-2NS_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;dxa:AccordionControl Name=&quot;accordion&quot; ItemsSource=&quot;{Binding MyData.Categories}&quot;/&gt;
</code></pre></section>

- C#
    - VB.NET

<section id="tabpanel_c581ci-2NS-1_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code class="lang-csharp">public class ViewModel {
    public Data MyData { get; set; }
    public ViewModel() {
        MyData = new Data();
    }
}
public class Data {
    public List&lt;Category&gt; Categories { get; set; }
    public Data() {
        Categories = GetCategories();
    }
    private static List&lt;Category&gt; GetCategories() { 
        // ... 
    }
}
public class Category {
    public string CategoryName { get; set; }
    public string Description { get; set; }
    public List&lt;Item&gt; Items { get; set; }
}
public class Item {
    public string ItemName { get; set; }
    public string Description { get; set; }
}
</code></pre></section>
<section id="tabpanel_c581ci-2NS-1_tabid-vb" role="tabpanel" data-tab="tabid-vb" aria-hidden="true" hidden="hidden">
<pre><code class="lang-vb">Public Class ViewModel
    Public Property MyData() As Data
    Public Sub New()
        MyData = New Data()
    End Sub
End Class
Public Class Data
    Public Property Categories() As List(Of Category)
    Public Sub New()
        Categories = GetCategories()            
    End Sub
    Private Shared Function GetCategories() As List(Of Category)
        &#39; ... 
    End Function 
End Class
Public Class Category
    Public Property CategoryName() As String
    Public Property Description() As String
    Public Property Items() As List(Of Item)
End Class
Public Class Item
    Public Property ItemName() As String
    Public Property Description() As String
End Class
</code></pre></section>
2. Create a class that implements the [IChildrenSelector](/WPF/DevExpress.Xpf.Accordion.IChildrenSelector) interface and assign its instance to the [AccordionControl.ChildrenSelector](/WPF/DevExpress.Xpf.Accordion.AccordionControl.ChildrenSelector) property:

- XAML

<section id="tabpanel_c581ci-2NS-2_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;dxa:AccordionControl Name=&quot;accordion&quot; ItemsSource=&quot;{Binding MyData.Categories}&quot; 
        ChildrenSelector=&quot;{StaticResource mySelector}&quot;/&gt;
</code></pre></section>

- C#
    - VB.NET

<section id="tabpanel_c581ci-2NS-3_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code class="lang-csharp">public class MySelector : IChildrenSelector {
    public IEnumerable SelectChildren(object item) {
        if(item is Category) {
            return ((Category)item).Items;
        } else {
            return null;
        }
    }
}
</code></pre></section>
<section id="tabpanel_c581ci-2NS-3_tabid-vb" role="tabpanel" data-tab="tabid-vb" aria-hidden="true" hidden="hidden">
<pre><code class="lang-vb">Public Class MySelector Implements IChildrenSelector
    Public Function SelectChildren(item As Object) As IEnumerable Implements IChildrenSelector.SelectChildren
        If TypeOf item Is Category Then
            Return DirectCast(item, Category).Items
        Else
            Return Nothing
        End If
    End Function
End Class
</code></pre></section>
3. Create a data template for each data source type to display the required information in accordion item headers:

- XAML

<section id="tabpanel_c581ci-2NS-4_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;dxa:AccordionControl Name=&quot;accordion&quot; ItemsSource=&quot;{Binding MyData.Categories}&quot; 
        ChildrenSelector=&quot;{StaticResource mySelector}&quot;&gt;
    &lt;dxa:AccordionControl.Resources&gt;
        &lt;DataTemplate DataType=&quot;{x:Type local:Category}&quot;&gt;
            &lt;TextBlock Text=&quot;{Binding CategoryName}&quot;/&gt;
        &lt;/DataTemplate&gt;
        &lt;DataTemplate DataType=&quot;{x:Type local:Item}&quot;&gt;
            &lt;TextBlock Text=&quot;{Binding ItemName}&quot;/&gt;
        &lt;/DataTemplate&gt;
    &lt;/dxa:AccordionControl.Resources&gt;
&lt;/dxa:AccordionControl&gt;
</code></pre></section>

The image below shows the result:

![AccordionDataBindingChildrenSelector](/WPF/images/accordiondatabindingchildrenselector132244.png)

## Example

- [How to: Bind the AccordionControl to Data Using the ChildrenSelector Property](/WPF/119898/controls-and-libraries/navigation-controls/accordion-control/examples/how-to-bind-the-accordioncontrol-to-data-using-the-childrenselector-property)