This is a migrated thread and some comments may be shown as answers.

AutoCompleteBox TextBoxStyle

2 Answers 203 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Matthias
Top achievements
Rank 1
Matthias asked on 24 Feb 2016, 02:44 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 25 Feb 2016, 10:13 AM
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
0
Matthias
Top achievements
Rank 1
answered on 16 Mar 2016, 08:10 AM

Thanks Yana, that worked.

Regards,
Matthias

Tags
AutoCompleteBox
Asked by
Matthias
Top achievements
Rank 1
Answers by
Yana
Telerik team
Matthias
Top achievements
Rank 1
Share this question
or