# RadHighlightTextBlock in an editable RadComboBox

## Environment

<table>
	<tbody>
		<tr>
			<th scope="row">Product Version</th>
			<td>2023.3.1011</td>
		</tr>
		<tr>
			<th scope="row">Product</th>
			<td>RadHighlightTextBlock for WPF</td>
		</tr>
	</tbody>
</table>

## Description

How to use `RadHighlightTextBlock` in an editable `RadComboBox`.

## Solution

Define a new `DataTemplate` that contains a RadHighlightTextBlock instance and set it to the `ItemTemplate` property of RadComboBox. Bind the `Text` property of the RadHighlightTextBlock to the property from the items' model that will be displayed in the RadComboBox instance. Bind the `HighlightText` property to the `Text` property of RadComboBox.

**Define the items' model and the view model**

```C#
    public class ItemInfo
    {
        public string Content { get; set; }
    }

    public class MainViewModel
    {
        public MainViewModel()
        {
            this.ItemInfos = new ObservableCollection<ItemInfo>()
            {
                new ItemInfo() { Content = "Item 1" },
                new ItemInfo() { Content = "Item 2" },
                new ItemInfo() { Content = "Item 3" },
            };
        }

        public ObservableCollection<ItemInfo> ItemInfos { get; set; }
    }
```

```VB.NET
    Public Class ItemInfo
        Public Property Content As String
    End Class

    Public Class MainViewModel
        Public Sub New()
            Me.ItemInfos = New ObservableCollection(Of ItemInfo)() From {
                New ItemInfo() With {
                    .Content = "Item 1"
                },
                New ItemInfo() With {
                    .Content = "Item 2"
                },
                New ItemInfo() With {
                    .Content = "Item 3"
                }
            }
        End Sub

        Public Property ItemInfos As ObservableCollection(Of ItemInfo)
    End Class
```

**Creating a DataTemplate with a RadHighlightTextBlock**

```XAML
    <DataTemplate x:Key="HighlightTextBlockDataTemplate">
        <telerik:RadHighlightTextBlock Text="{Binding Content}" 
                                       HighlightText="{Binding Path=Text, RelativeSource={RelativeSource    AncestorType=telerik:RadComboBox}, Mode=TwoWay}"/>
    </DataTemplate>
```

**Set the custom DataTemplate to the ItemTemplate property of RadComboBox**

```XAML
    <telerik:RadComboBox IsEditable="True"
                         ItemsSource="{Binding ItemInfos}"
                         telerik:TextSearch.TextPath="Content"
                         ItemTemplate="{StaticResource HighlightTextBlockDataTemplate}"/>
```

> caption RadComboBox with RadHighlightTextBlock

![WPF RadComboBox with RadHighlightTextBlock](https://www.telerik.com/products/wpf/documentation/assets/e20630e949af0b5714daca92d6db7544/kb-highlighttextblock-integration-with-radcombobox-0.png)

> important Integration with the RadHighlightTextBlock control and enabled autocomplete functionality is not supported. If you need highlighting in an autocomplete scenario, you can check the [RadHighlightTextBlock with RadAutoCompleteBox](https://www.telerik.com/products/wpf/documentation/knowledge-base/kb-highlighttextblock-integration-with-radautocompletebox) and [RadHighlightTextBlock with RadAutoSuggestBox](https://www.telerik.com/products/wpf/documentation/knowledge-base/kb-highlighttextblock-integration-with-radautosuggestbox) articles.
