# Getting Started with WPF AutoSuggestBox

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

## Adding Telerik Assemblies Using NuGet

To use **RadAutoSuggestBox** 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**

You can find the required assemblies for each control from the suite in the [Controls Dependencies](https://www.telerik.com/products/wpf/documentation/common-information/installation-installing-dependencies-wpf) help article.

## Adding Telerik Assemblies Using NuGet

To use **RadAutoSuggestBox** 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).

## Defining RadAutoSuggestBox

RadAutoSuggestBox allows you to visualize a list of search results on demand when you enter text. When the text in the control changes, the **TextChanged** event is fired, where you can filter the ItemsSource of the control. This will open the drop down and display the filtered items.

In the following example you will see a sample data provider that returns a list of countries that is filtered and displayed on text changed.

**Example 1: Creating sample data provider**

```C#
public static class CountryDataProvider
{
    public static List<CountryInfo> Countries { get; set; }

    static CountryDataProvider()
    {
        Countries = new List<CountryInfo>();
        var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
        foreach (CultureInfo culture in cultures)
        {
            var regionInfo = new RegionInfo(culture.LCID);
            if (!Countries.Any(x => x.Name.Equals(regionInfo.EnglishName)))
            {
                Countries.Add(new CountryInfo() { Name = regionInfo.EnglishName });
            }
        }
    }

    public static List<CountryInfo> GetCountriesByText(string searchText)
    {
        var result = new List<CountryInfo>();
        var lowerText = searchText.ToLowerInvariant();
        return Countries.Where(x => x.Name.ToLowerInvariant().Contains(lowerText)).ToList();
    }
}

public class CountryInfo
{
    public string Name { get; set; }
}
```

**Example 2: Defining RadAutoSuggestBox and subscribing to TextChanged**

```XAML
<telerik:RadAutoSuggestBox x:Name="radAutoSuggestBox"
							   TextChanged="RadAutoSuggestBox_TextChanged"
							   DisplayMemberPath="Name" 
							   TextMemberPath="Name" 							   
							   WatermarkContent="Type here" 
							   NoResultsContent="No results found" />
```

**Example 3: Implementing filtering in the TextChanged event handler**

```C#
private void RadAutoSuggestBox_TextChanged(object sender, Telerik.Windows.Controls.AutoSuggestBox.TextChangedEventArgs e)
{
    if (e.Reason == TextChangeReason.UserInput)
    {
        this.radAutoSuggestBox.ItemsSource = CountryDataProvider.GetCountriesByText(this.radAutoSuggestBox.Text);
    }
}
```

The definition in **Example 2** has few additional settings:

* **DisplayMemberPath**: Specifies the property path used to get the value displayed for each data item in the drop down of the RadAutoSuggestBox control.
* **TextMemberPath**: Specifies the property path used to get the value displayed in the TextBox of the control.
* **WatermarkContent**: Specifies the value displayed in the TextBox of the control when no text is entered.
* **NoResultsContent**: Specifies the value displayed in the drop down when no results are presented in the ItemsSource of the control.

> tip Use the **Text** property to get or set the current query or suggestion text.

> caption Watermark content when no text is entered

![WPF RadAutoSuggestBox Watermark content when no text is entered](https://www.telerik.com/products/wpf/documentation/assets/7600dff7d35d2ba99481caa6b83039f1/radautosuggestbox-getting-started-0.png)

> caption Filtered results in the drop down

![WPF RadAutoSuggestBox Filtered results in the drop down](https://www.telerik.com/products/wpf/documentation/assets/8c2214a41ca756ee95716b76d04a23cf/radautosuggestbox-getting-started-1.png)

> caption No result

![WPF RadAutoSuggestBox No result](https://www.telerik.com/products/wpf/documentation/assets/957a42e3528c2bd6805c0c882b916515/radautosuggestbox-getting-started-2.png)

After selecting an item from the drop down list or click on the query icon, you can use **QuerySubmitted** and **SuggestionChosen** events to execute additional actions.

## Open Drop Down Manually

The drop down of the control can be opened or closed manually by setting its **IsDropDownOpen** property.

**Example 2: Setting IsDropDownOpen**

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

## 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.Fluent.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 **RadAutoSuggestBox**, you will need to merge the following resources:

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

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

**Example 3: Merge the ResourceDictionaries**

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

> 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 2** shows a **RadAutoSuggestBox** with the **Fluent** theme applied.

> caption RadAutoSuggestBox with the fluent theme

![RadAutoSuggestBox with Fluent theme](https://www.telerik.com/products/wpf/documentation/assets/cb907c13b792af613e6c86c3403c737c/radautosuggestbox-setting-theme.png)

## Customizing Appearance

RadAutoSuggestBox allows you to customize the appearance of its TextBox, buttons and items. You can read more about this in the [Customizing Appearance](https://www.telerik.com/products/wpf/documentation/controls/radautosuggestbox/appearance/customize-buttons) section of the control's documentation.

## Telerik UI for WPF Learning Resources

* [Telerik UI for WPF AutoSuggestBox Component](https://www.telerik.com/products/wpf/autosuggestbox.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

* [Watermark](https://www.telerik.com/products/wpf/documentation/controls/radautosuggestbox/features/watermark)
* [Visual Structure](https://www.telerik.com/products/wpf/documentation/controls/radautosuggestbox/visual-structure)
* [Grouping](https://www.telerik.com/products/wpf/documentation/controls/radautosuggestbox/features/grouping)
* [Events](https://www.telerik.com/products/wpf/documentation/controls/radautosuggestbox/events)
