Prepoulate and receive all selected items

2 posts, 0 answers
  1. Bjoern
    Bjoern avatar
    1 posts
    Member since:
    Apr 2016

    Posted 26 Apr 2016 Link to this post

    Hi there, 

    I am currently testing the autocompletebox in our project and I am having some troubles understanding certain parts of it. I had a look at the documentation and the examples, but they have not really helped me. 


    Our scenario is simple: 

    A user wants to send a message to another user. The ACB is used to search for the contact and add it to the recipients list. (At least thats the plan)

    We have an ObservableCollection holding all Contacts of a user. I have bound that to the ItemsSource of the ACB. 


    <telerik:RadAutoCompleteBox x:Name="txtSearchBoxCC"
                                ItemsSource="{Binding ContactsList}"
                                DisplayMemberPath="Fullname" />

    The ACB works as intended, I can search and select contacts as I wish. 

    My problem is, that I would just like to check for all the selected Items in the ACB by the time the user hits "send". 

    Also, how can I prepopulate the Textbox with some of the Items in the ItemsSource ? 

  2. Yana
    Yana avatar
    4604 posts

    Posted 27 Apr 2016 Link to this post

    Hi Bjoern,

    You could use SelectedItems property of RadAutoCompleteBox to get/set the currently selected Contacts in the concrete case. SelectedItems could be bound to a collection in the ViewModel in the same way as ItemSource and  this collection could be populated with some items from the ContactsList collection, so that they are pre-selected in the AutoCompleteBox. Here is a quick example:

    this.SelectedContacts = new ObservableCollection<Contact>()

    <telerik:RadAutoCompleteBox ItemsSource="{Binding ContactsList}"
         SelectedItems="{Binding SelectedContacts}" />

    I hope this will be helpful.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top