Edit this page

Create a Watermark

Before proceeding further with this tutorial, be sure that you are familiar with how to bind a RadComboBox to a collection of business objects. For more information take a look at the Binding to Object topic. This tutorial will use exactly the same example as in the aforemendoned topic.

EmptyText property

If you have a RadComboBox which is populated to a collection of business objects, then to set the EmptyText property all we need to do is to define the ComboBox in xaml:

<telerik:RadComboBox ItemsSource="{Binding Source={StaticResource DataSource}, Path=Agency}" DisplayMemberPath="Name" IsEditable="True" EmptyText="Please select an agency" />

The result is shown on the image below.

If the IsEditable property is false the result would be like this:

If the IsEditable property of the ComboBox is set to True and the control is on focus the EmptyText is not displayed.

EmptySelectionBoxTemplate

The EmptySelectionBoxTemplate gives you the ability to define a separate template when there is no selected item. The purpose of this tutorial is to show you how to create and apply EmptySelectionBoxTemplate.

If we use the aforementioned RadComboBox, it gives you the ability to define a separate template for the empty selection box. In order to do that, you will have to perform two simple steps:

  • Create a custom DataTemplate

<UserControl.Resources>
  <DataTemplate x:Key="EmptyTemplate">
      <TextBlock FontWeight="Bold" FontFamily="Comic Sans" FontStyle="Italic" Text="Please select an agency" />
  </DataTemplate>
</UserControl.Resources>
  • Set the declared DataTemplate to the RadComboBox's EmptySelectionBoxTemplate property.

<telerik:RadComboBox ItemsSource="{Binding Source={StaticResource DataSource}, Path=Agency}" DisplayMemberPath="Name" EmptySelectionBoxTemplate="{StaticResource EmptyTemplate}" IsEditable="False" />

The result is shown on the image below. Note how there is a text displayed without an item is being selected.

The EmptySelectionBoxTemplate property only works if the RadComboBox is in non-editable mode, i.e its IsEditable property is set to False. Otherwise, it is applied the EmptyText property.