Style Radcombobox watermark/emptytext

4 posts, 0 answers
  1. Mads
    Mads avatar
    25 posts
    Member since:
    Nov 2014

    Posted 15 Sep 2015 Link to this post

    I want to add a style to the emptytext of the radcombobox that works across the entire application. 

     From what I can see I have to use but if I use 

    <DataTemplate x:Key="EmptyTemplate">
     <TextBlock FontWeight="Bold" FontFamily="Comic Sans" FontStyle="Italic" Text="Please select an agency" />
     Then I cant specify the text in the control that uses it like

    <telerik:RadComboBox Grid.Column="3"
                                     SelectedItem="{Binding Path=CreateVetPcrTestSignup.SelectedVetPcrTestKit}"
                                     EmptySelectionBoxTemplate="{StaticResource EmptyTemplate}"
                                     EmptyText="{x:Static localization:SignupTexts.PcrKitDefaultValue}"
                                     ItemsSource="{Binding Path=PcrTestKits}" />


    I want {x:Static localization:SignupTexts.PcrKitDefaultValue} to be used here, but I of course get "Please select an agency", I tried removing the name from the template, but then its just empty. Is there a way to parse the empty text into the template or use a styling somehow that only affects the emptytext?

  2. Nasko
    Nasko avatar
    727 posts

    Posted 18 Sep 2015 Link to this post

    Hello Mads,

    In order to apply the desired Template for the EmptyText and at the same time preserve its value the Text property of the TextBlock placed inside the DataTemplate should be bound to the EmptyText property of RadComboBox.

    We have created a sample project that demonstrates that and you could run and evaluate it.

    Hopes this helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Anish
    Anish avatar
    2 posts
    Member since:
    Jul 2018

    Posted 31 Jul 2018 in reply to Nasko Link to this post

    Hi.. Is there any way I can implement this with IsEditable="True". If not how do I achieve this?
  4. Dinko
    Dinko avatar
    1109 posts

    Posted 31 Jul 2018 Link to this post

    Hello Anish,

    The EmptySelectionBoxTemplate is applied only for non-editable ComboBox. The watermark of RadComboBox is presented with a TextBlock with x:Name="Watermark", so In the described case you could find the TextBlock and set its properties with code. You can subscribe to the Loaded event handler of the RadComboBox and use our ChildrenOfType<T>() extension method you can get the TextBlock. Check the following code snippet.
    private void combo_Loaded(object sender, RoutedEventArgs e)
        var comboBox = sender as RadComboBox;
        TextBlock watermarkTextBlock = comboBox.ChildrenOfType<TextBlock>().FirstOrDefault(x=>x.Name == "Watermark");
        if (watermarkTextBlock != null)
            watermarkTextBlock.FontWeight = FontWeights.Bold;
            watermarkTextBlock.FontFamily = new FontFamily("Comic Sans");
            watermarkTextBlock.Opacity = 1;
            watermarkTextBlock.FontStyle = FontStyles.Italic;

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top