AutoCompleteBox TextBoxStyle

3 posts, 1 answers
  1. Matthias
    Matthias avatar
    9 posts
    Member since:
    Jan 2016

    Posted 24 Feb 2016 Link to this post


    when I override the TextBoxStyle of the RadAutoCompleteBox with my own styledTextBox (according to this suggestion), it results in wired behavior. When I enter the first character the SearchText binding fires twice with empty string. All following keyboard hits trigger the binding once but still with an empty string. The control however displays all entered characters except the first one.

    Here's the custom style:

    <Style x:Key="customStyle" TargetType="telerik:RadWatermarkTextBox">
        <Setter Property="Template">
                <ControlTemplate TargetType="telerik:RadWatermarkTextBox">
                    <TextBox Text="{Binding SearchText, RelativeSource={RelativeSource AncestorType=telerik:RadAutoCompleteBox}, Mode=TwoWay}" />

    and the control itself:

        ItemsSource="{Binding CustomerSearchProvider}"
        SelectedItem="{Binding CustomerSearchProvider.Selected, Mode=TwoWay}"
        SearchText="{Binding CustomerSearchProvider.SearchTerm, Mode=TwoWay}"
        IsDropDownOpen="{Binding CustomerSearchProvider.IsCompleted}"
        TextBoxStyle="{StaticResource customStyle}">

    When I remove the TextBoxStyle, everything works as expected.



  2. Answer
    Yana avatar
    5043 posts

    Posted 25 Feb 2016 Link to this post

    Hi Matthias,

    The reason for the erroneous behavior is that the used template for RadWatermarkTextBox is incomplete - some required parts are missing in order for the the control to work properly.  You should copy the default TextBoxStyle according to the used theme and made the needed changes inside it. Please take a look at the Editing Control Templates topic for more details on the approach.

    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. Matthias
    Matthias avatar
    9 posts
    Member since:
    Jan 2016

    Posted 16 Mar 2016 Link to this post

    Thanks Yana, that worked.


Back to Top