# Binding To Object

To bind **RadAutoCompleteBox** to a collection of business object, you should use its ItemsSource property.

The following example will guide you through the process of binding your RadAutoCompleteBox to a collection of business objects. The example includes:

* [Binding the ItemsSource](https://www.telerik.com/products/wpf/documentation/controls/radautocompletebox/populating-with-data/binding-to-object#binding-the-itemssource)

* [Using DisplayMemberPath and TextSearchPath](https://www.telerik.com/products/wpf/documentation/controls/radautocompletebox/populating-with-data/binding-to-object#using-displaymemberpath-and-textsearchpath)

> tip Before proceeding with this tutorial you should get familiar with the [Data Binding](https://www.telerik.com/products/wpf/documentation/controls/radautocompletebox/populating-with-data/binding-support-overview) support of the RadAutoCompleteBox control.

## Binding the ItemsSource

1. First you will need to add **RadAutoCompleteBox** to your project:

   **Add RadAutoCompleteBox**

```XAML
<telerik:RadAutoCompleteBox />
```

1. Create a business object called Country:

   **Creation of the object**

```C#
public class Country
{
    public string Name { get; set; }
    public string Capital { get; set; }
}
```

1. Create a new class named **ViewModel**. In fact, this will be the data source for the RadAutoCompleteBox and this class has only one purpose - to initialize a collection with sample data.

   **ViewModel creation**

```C#
public class ViewModel
{
    public ObservableCollection<Country> Countries { get; set; }
    public ViewModel()
    {
        this.Countries = new ObservableCollection<Country>()
                {
                    new Country() { Name = "Australia", Capital = "Canberra" },
                    new Country() { Name = "Bulgaria", Capital = "Sofia" },
                    new Country() { Name = "Canada", Capital = "Ottawa" },
                    new Country() { Name = "Denmark", Capital = "Copenhagen" },
                    new Country() { Name = "France", Capital = "Paris" },
                    new Country() { Name = "Germany", Capital = "Berlin" },
                    new Country() { Name = "India", Capital = "New Delhi" },
                    new Country() { Name = "Italy", Capital = "Rome" },
                    new Country() { Name = "Norway", Capital = "Oslo" },
                    new Country() { Name = "Russia", Capital = "Moscow" },
                    new Country() { Name = "Spain ", Capital = "Madrid" },
                    new Country() { Name = "United Kingdom", Capital = "London" },
                    new Country() { Name = "United States", Capital = "Washington, D.C." },
                };
    }
}
```

1. Declare the **ViewModel** as a resource in your XAML:

   **Declaring the ViewModel**

```XAML
<UserControl.Resources>
    <local:ViewModel x:Key="ViewModel"/>
</UserControl.Resources>
```

1. Update your **RadAutoCompleteBox** declaration and its **ItemsSource** property:

   **Update the ItemsSource property**

```XAML
<telerik:RadAutoCompleteBox ItemsSource="{Binding Countries, Source={StaticResource ViewModel}}"/>
```

1. Set the DisplayMemberPath property of the control.

   **Setting the DisplayMemberPath**

```XAML
<telerik:RadAutoCompleteBox ItemsSource="{Binding Countries, Source={StaticResource ViewModel}}"
		                            DisplayMemberPath="Name"/>
```

The next screenshots show the final result:

![radautocompletebox-features-autocomplete-1](https://www.telerik.com/products/wpf/documentation/assets/2da6670f05aa5842f03efeabada2496d/radautocompletebox-features-autocomplete-1.png)

![radautocompletebox-populating-with-data-binding-to-object-3](https://www.telerik.com/products/wpf/documentation/assets/49d1ed3870a3ce6bb142b4bb843e5e24/radautocompletebox-populating-with-data-binding-to-object-3.png)

![radautocompletebox-populating-with-data-binding-to-object-2](https://www.telerik.com/products/wpf/documentation/assets/82434745b5d055a99db9409461347f68/radautocompletebox-populating-with-data-binding-to-object-2.png)

## Using DisplayMemberPath and TextSearchPath

Setting both **DisplayMemberPath** and **TextSearchPath** properties will allow to search by specific property of the business object and at the same time display a different property in the DropDown and in the TextBox after selection.

In the next code snippets we will demonstrate how to use these properties together by extending the previous example from the [Binding the ItemsSource](https://www.telerik.com/products/wpf/documentation/controls/radautocompletebox/populating-with-data/binding-to-object#binding-the-itemssource) section:

1. Set the **DisplayMemberPath** to a specific property of the used business object:

   **Setting the DisplayMemberPath**

```XAML
<telerik:RadAutoCompleteBox ItemsSource="{Binding Countries, Source={StaticResource ViewModel}}"
		                            DisplayMemberPath="Name"/>
```

1. Set the **TextSearchPath** to a specific property of the used business object:

   **Setting the TextSearchPath**

```XAML
<telerik:RadAutoCompleteBox ItemsSource="{Binding Countries, Source={StaticResource ViewModel}}"
		                            DisplayMemberPath="Name"
		                            TextSearchPath="Capital"/>
```

The next screenshots show how **RadAutoCompleteBox** behaves when its DisplayMemberPath and TextSearchPath properties are set:

![radautocompletebox-features-autocomplete-1](https://www.telerik.com/products/wpf/documentation/assets/2da6670f05aa5842f03efeabada2496d/radautocompletebox-features-autocomplete-1.png)

![radautocompletebox-populating-with-data-binding-to-object-1](https://www.telerik.com/products/wpf/documentation/assets/c184ced758b8e2aa4ae15486f6c73191/radautocompletebox-populating-with-data-binding-to-object-1.png)

![radautocompletebox-populating-with-data-binding-to-object-2](https://www.telerik.com/products/wpf/documentation/assets/82434745b5d055a99db9409461347f68/radautocompletebox-populating-with-data-binding-to-object-2.png)
