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

Can AutoCompleteBox work like a TextBox with Autocomplete?

2 Answers 192 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 29 Jan 2014, 01:42 PM
Hi,

I thought (from the first look it seems so) AutoCompleteBox is what I'm looking for.
Searching the help I found not a single word how to bind Text with this control.

Further investigations brought me to a mix of "SearchText" and "SelectedItems" - which barely works

Anyhow - what I expected was:
a.) A TextBox (with validation and binding for the text)
b.) Suggestions with the possibility to choose (and also change) an item

Or (except for Validation) - the thing you see in Internet Explorer.

Can I do this with RadAutoCompleteBox?

Approach:
User has give a "Reason" for something.
In my Model I have Item.Reason - which must be filled.
Since the resons are often the same - I have a list of default reasons - as suggestions whild entering text.
The user chan choose an existing one - his own one - at the end there is text in the box - which has to be validated (IDataErrorInfo)
If it fails  - red markers.....

Manfred

2 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 03 Feb 2014, 09:02 AM
Hello,

By design the RadAutoCompleteBox control is designed to support validation but not out of the box because there isn't a one validation fits all approach that could be built-in in the control. The control is designed to support any of the well known object validation approaches used (for example implementing IDataErrorInfo).

We are not sure what scenario you are exactly trying to achieve but if you want to have validation for when there is not a selected item and allow a custom entry for selected item you could do the following:
  • Implement the IDataErrorInfo interface in your ViewModel
  • Create a property for the SelectedItem/SelectedItems depending on the mode in which you are using the control
  • Create a bool property that should indicate if a custom entry should be added to the ItemsSource collection and set a SelectedItem
  • Bind those properties to the control and add a button (or other implementation) that will add the "custom" selected item

I created a sample project of the described approach for you. Note that this is an example project which purpose is to illustrate a possible solution to the described desired behavior. Hope this is helpful.


Regards,
Vladi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ManniAT
Top achievements
Rank 2
answered on 03 Feb 2014, 09:50 AM
Hi Vladi,

your solution didn't solve my problem.
Anyhow - I got what I want by simply using a RadComboBox (altering some styles).

Thank you for you help
Manfred
Tags
AutoCompleteBox
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Vladi
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or