How to replace an ObservableCollection with links


Hello I'm trying to Populate an Observable Collection through selected items of an Autocompletebox.

<Telerik:RadAutoCompleteBox Itemssource="{Binding People}" />

How should I initiate the Observable Collection to bind with RadAutocompleteBox. And how should I set up SelectedItems binding method.

public class People
    public string Person
    { get; set; }
    public DateTime Date
    { get; set; }

public ObservableCollection<string> Persons{ get; set; }

You could try this to get the SelectedItems :

Add this to your viewmodel and edit your XAML. ViewModel:

public ObservableCollection<People> SelectedPeoples { get; set; }


  <Telerik:RadAutoCompleteBox Itemssource="{Binding People}"
    SelectedItems="{Binding SelectedPeoples , Mode=TwoWay}"
    SelectionMode="Multiple" />

After your edit

I see that you try to bind a class to the RadAutoCompleteBox rather than the ObservableCollection People, you have to bind the property Persons to the RadAutocompleteBox. This will bind the ObservableCollection to the RadAutoCompleteBox.

<Telerik:RadAutoCompleteBox Itemssource="{Binding Persons}" />

Also, you can edit the declaration of your ObservableCollection to

public ObservableCollection<People> Persons{ get; set; }

and edit the XAML like this:

<Telerik:RadAutoCompleteBox Itemssource="{Binding Persons}" DataMemberPath="Person" />

Your RadAutocompleteBox will now show the string Person declared in your People class.