Change EmptyText to ClearSelectionButtonContent

2 posts, 1 answers
  1. yjh
    yjh avatar
    67 posts
    Member since:
    Aug 2007

    Posted 11 Jul 2011 Link to this post

    Is there a way to change EmptyText to ClearSelectionButtonContent when click the ClearSelectionButton ?
  2. Answer
    Pana avatar
    748 posts

    Posted 13 Jul 2011 Link to this post


    You can. Create a Converter and bind the


    to the SelectedItem of the RadComboBox. In the converter based on the value you can return two different strings:

        <local:SelectedItemToClearTextConverter x:Key="Convert" />
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadComboBox x:Name="Combo" Width="150" Height="22" SelectedIndex="0" ClearSelectionButtonVisibility="Visible" ClearSelectionButtonContent="{Binding ElementName=Combo, Path=SelectedItem, Converter={StaticResource Convert}}">
            <telerik:RadComboBoxItem Content="Item 1" />
            <telerik:RadComboBoxItem Content="Item 2" />
            <telerik:RadComboBoxItem Content="Item 3" />
            <telerik:RadComboBoxItem Content="Item 4" />
            <telerik:RadComboBoxItem Content="Item 5" />
            <telerik:RadComboBoxItem Content="Item 6" />

    With converter:

    public class SelectedItemToClearTextConverter : IValueConverter
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            if (value == null)
                return "Can not unselect null";
                return "Unselect";
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            throw new NotImplementedException();

    There is also an attached project.

    As I think of it with the same success you can bind the visibility of the button so it could be hidden when there is no selected item.

    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top