# Getting Started with WPF ComboBox

This tutorial will walk you through the creation of a sample application that contains **RadComboBox**.

## Adding Telerik Assemblies Using NuGet

To use **RadComboBox** when working with NuGet packages, install the `Telerik.Windows.Controls.Input.for.Wpf.Xaml` package. The [package name may vary](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/nuget/available-packages) slightly based on the Telerik dlls set - [Xaml or NoXaml](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/xaml-vs-noxaml)

Read more about NuGet installation in the [Installing UI for WPF from NuGet Package](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/nuget/nuget-installation) article.

> tip With the 2025 Q1 release, the Telerik UI for WPF has a new licensing mechanism. You can learn more about it [here](https://www.telerik.com/products/wpf/documentation/installation/licensing/installing-license-key).

## Adding Assembly References Manually

If you are not using NuGet packages, you can add a reference to the following assemblies:

* **Telerik.Licensing.Runtime**
* **Telerik.Windows.Controls**
* **Telerik.Windows.Controls.Input**

## Adding RadComboBox to the Project

Before proceeding with adding **RadComboBox** to your project, make sure the required assembly references are added to the project.

You can add **RadComboBox** manually by writing the XAML code in **Example 1**. You can also add the control by dragging it from the Visual Studio Toolbox and dropping it over the XAML view.

**Example 1: Adding RadComboBox in XAML**

```XAML
<telerik:RadComboBox Width="100" />
```

> In order to use **RadComboBox** in XAML you have to add the namespace declaration shown in **Example 2**:
> **Example 2: Declaring Telerik Namespace**
>
> ```XAML
>    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
> ```

If you run the application you will see an empty ComboBox as demonstrated in **Figure 1**.

> caption The empty ComboBox generated by the code in example 1

![WPF RadComboBox The empty ComboBox generated by the code in Example 1](https://www.telerik.com/products/wpf/documentation/assets/8d7cee433b99cecd59aecd9a5a091a64/radcombobox_gettingstarted_0.png)

## Populating with Data

In order to populate the **RadComboBox** control with data in XAML, you should add a few **RadComboBoxItems** to it and set their Content property as in **Example 3**.

**Example 3: Adding RadComboBoxItems in XAML**

```XAML
<telerik:RadComboBox Width="100">
    <telerik:RadComboBoxItem Content="Item 1" />
    <telerik:RadComboBoxItem Content="Item 2" />
</telerik:RadComboBox>
```

Running the application will result in a populated **RadComboBox** as shown in **Figure 2**.

> caption RadComboBox with static items

![WPF RadComboBox RadComboBox with static items](https://www.telerik.com/products/wpf/documentation/assets/f6ded1ba6d9354b664f07afd3fdc872d/radcombobox_gettingstarted_1.png)

Adding static **RadComboBoxItems** in XAML is good in scenarios when you know in advance the data in the combo box. However, in most cases, you have to bind your **RadComboBox** to a collection of business objects. For the purposes of this example, create a new class named Car and add several properties to it as shown in **Example 4**.

**Example 4: Simple business class**

```C#
public class Car
{
    public string Make { get; set; }
    public string Model { get; set; }

    public Car(string make, string model)
    {
        this.Make = make;
        this.Model = model;
    }
}
```

```VB.NET
Public Class Car
	Public Property Make() As String
		Get
			Return m_Make
		End Get
		Set(value As String)
			m_Make = Value
		End Set
	End Property
	Private m_Make As String

	Public Property Model() As String
		Get
			Return m_Model
		End Get
		Set(value As String)
			m_Model = Value
		End Set
	End Property
	Private m_Model As String

	Public Sub New(make As String, model As String)
		Me.Make = make
		Me.Model = model
	End Sub
End Class
```

Next, you should create the view model containing a collection of Car objects.

**Example 5: View model containing ObservableCollection of sample data**

```C#
public class MyViewModel
{
    private ObservableCollection<Car> cars;

    public ObservableCollection<Car> Cars
    {
        get
        {
            if (this.cars == null)
            {
                this.cars = this.CreateCars();
            }
            return this.cars;
        }
    }

    private ObservableCollection<Car> CreateCars()
    {
        ObservableCollection<Car> cars = new ObservableCollection<Car>()
           {
               new Car("Opel", "Vectra"),
               new Car("Ford", "Focus"),
               new Car("Fiat", "Bravo")
           };
        return cars;
    }
}
```

```VB.NET
Public Class MyViewModel
   
	Private m_cars As ObservableCollection(Of Car)

	Public ReadOnly Property Cars() As ObservableCollection(Of Car)
		Get
			If Me.m_cars Is Nothing Then
				Me.m_cars = Me.CreateCars()
			End If
			Return Me.m_cars
		End Get
	End Property

	Private Function CreateCars() As ObservableCollection(Of Car)
		Dim cars As New ObservableCollection(Of Car)() From {
			New Car("Opel", "Vectra"),
			New Car("Ford", "Focus"),
			New Car("Fiat", "Bravo")
		}
		Return cars
	End Function
End Class
```

Now that you have prepared the needed sample data, it is time to bind **RadComboBox** to it. For that purpose, you should set the **RadComboBox's ItemsSource** property to the collection of cars. Additionally, you should set **DisplayMemberPath** property to mark which property of the business object will be used as its visual representation inside **RadComboBox**.

**Example 6** demonstrates how you can bind the ItemsSource collection in XAML. The *local* namespace in the example corresponds to the namespace where **MyViewModel** resides.

**Example 6: Bind RadComboBox**

```XAML
<Grid.Resources>
    <local:MyViewModel x:Key="MyViewModel" />
</Grid.Resources>
<telerik:RadComboBox Width="100" DataContext="{StaticResource MyViewModel}" ItemsSource="{Binding Cars}" 
DisplayMemberPath="Make" />
```

Running the application at this stage will result in a populated **RadComboBox** like in **Figure 3**.

> caption RadComboBox bound to collection of cars

![Telerik UI for WPF RadComboBox bound to a collection of cars](https://www.telerik.com/products/wpf/documentation/assets/a1636e19305add13a4e0816817e7a639/radcombobox_gettingstarted_2.png)

## Working with AutoComplete

**AutoComplete** is a feature provided by many browsers, programs and controls. It involves the program predicting a word or phrase that the user wants to type without the user actually typing it in completely. **RadComboBox** has full autocomplete support - while you type into the input area, the combo box returns the relative match for the currently typed text. [Read more](https://www.telerik.com/products/wpf/documentation/controls/radcombobox/features/autocomplete)

## Working with Edit Modes

The **RadComboBox** can be editable, allowing the user to type in its text box, or non-editable, where the text box is hidden. In addition, you could make the text box read only in order to keep the editable look but prevent the user from typing. The **RadComboBox**'s API exposes several properties, allowing you to configure these modes. [Read more](https://www.telerik.com/products/wpf/documentation/controls/radcombobox/features/edit-modes)

## Opening and Closing DropDown Manually

To open or close the dropdown content of RadComboBox manually, set its **IsDropDownOpen** property.

**Example 7: Open dropdown manually**

```XAML
<telerik:RadComboBox IsDropDownOpen="True" />
```

## Setting DropDown Size

RadComboBox allows you to set the width and the max height of the dropdown content. To do this, set the **DropDownWidth** and **MaxDropDownHeight** properties of RadComboBox.

**Example 8: Set dropdown content size**

```XAML
<telerik:RadComboBox MaxDropDownHeight="200" DropDownWidth="150" />
```

## Setting a Theme

The controls from our suite support different themes. You can see how to apply a theme different than the default one in the [Setting a Theme](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-setting-a-theme-overview) help article.

> important Changing the theme using implicit styles will affect all controls that have styles defined in the merged resource dictionaries. This is applicable only for the controls in the scope in which the resources are merged.

To change the theme, you can follow the steps below:

* Choose between the themes and add reference to the corresponding theme assembly (ex: **Telerik.Windows.Themes.Windows8.dll**). You can see the different themes applied in the **Theming** examples from our [WPF Controls Examples](https://demos.telerik.com/wpf/) application.

* Merge the ResourceDictionaries with the namespace required for the controls that you are using from the theme assembly. For the **RadComboBox**, you will need to merge the following resources:

  * **Telerik.Windows.Controls**
  * **Telerik.Windows.Controls.Input**

**Example 9** demonstrates how to merge the ResourceDictionaries so that they are applied globally for the entire application.

**Example 9: Merge the ResourceDictionaries**

```XAML
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
```

> Alternatively, you can use the theme of the control via the [StyleManager](https://docs.telerik.com/devtools/wpf/styling-and-appearance/stylemanager/common-styling-apperance-setting-theme-wpf).

**Figure 4** shows a **RadComboBox** with the **Windows8** theme applied.

> caption RadComboBox with the Windows8 theme

![RadComboBox with Windows8 theme](https://www.telerik.com/products/wpf/documentation/assets/2026c20568432cd31081fe3dd7c18233/radcombobox-setting-theme.png)

## Telerik UI for WPF Learning Resources

* [Telerik UI for WPF ComboBox Component](https://www.telerik.com/products/wpf/combobox.aspx)
* [Getting Started with Telerik UI for WPF Components](https://www.telerik.com/products/wpf/documentation/getting-started/first-steps-nuget)
* [Telerik UI for WPF Installation](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/installation-guide)
* [Telerik UI for WPF and WinForms Integration](https://www.telerik.com/products/wpf/documentation/common-information/winforms-integration/overview)
* [Telerik UI for WPF Visual Studio Templates](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/visual-studio-templates)
* [Setting a Theme with Telerik UI for WPF](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-setting-a-theme-overview)
* [Telerik UI for WPF Virtual Classroom (Training Courses for Registered Users)](https://learn.telerik.com/learn/course/external/view/elearning/16/telerik-ui-for-wpf)
* [Telerik UI for WPF License Agreement](https://www.telerik.com/purchase/license-agreement/wpf-dlw-s)

## See Also

* [AutoComplete](https://www.telerik.com/products/wpf/documentation/controls/radcombobox/features/autocomplete)
* [Edit Modes](https://www.telerik.com/products/wpf/documentation/controls/radcombobox/features/edit-modes)
