Can AutoCompleteBox work like a TextBox with Autocomplete?

3 posts, 0 answers
  1. ManniAT
    ManniAT avatar
    885 posts
    Member since:
    Nov 2003

    Posted 29 Jan 2014 Link to this post


    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?

    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.....

  2. Vladi
    Vladi avatar
    749 posts

    Posted 03 Feb 2014 Link to this post


    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.

    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 >>
  3. ManniAT
    ManniAT avatar
    885 posts
    Member since:
    Nov 2003

    Posted 03 Feb 2014 in reply to Vladi Link to this post

    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
Back to Top