AutoCompleteBox TextBoxStyle

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

    Posted 24 Feb Link to this post

    Hi,

    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">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:RadWatermarkTextBox">
                    <TextBox Text="{Binding SearchText, RelativeSource={RelativeSource AncestorType=telerik:RadAutoCompleteBox}, Mode=TwoWay}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    and the control itself:

    <telerik:RadAutoCompleteBox
        ItemsSource="{Binding CustomerSearchProvider}"
        SelectedItem="{Binding CustomerSearchProvider.Selected, Mode=TwoWay}"
        SearchText="{Binding CustomerSearchProvider.SearchTerm, Mode=TwoWay}"
        IsDropDownOpen="{Binding CustomerSearchProvider.IsCompleted}"
        DisplayMemberPath="DisplayName"
        TextSearchMode="Contains"
        SelectionMode="Single"
        TextBoxStyle="{StaticResource customStyle}">

    When I remove the TextBoxStyle, everything works as expected.

    Thanks

    Matthias

  2. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 25 Feb 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.

    Regards,
    Yana
    Telerik
    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. UI for WPF is Visual Studio 2017 Ready
  4. Matthias
    Matthias avatar
    6 posts
    Member since:
    Jan 2016

    Posted 16 Mar Link to this post

    Thanks Yana, that worked.

    Regards,
    Matthias

Back to Top