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

Pre-populate values in AutoCompleteTextBox

4 Answers 90 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Art Kedzierski
Top achievements
Rank 2
Art Kedzierski asked on 04 Sep 2013, 08:12 PM
I'm using the RadAutoCompleteBox as a people picker (Attendees) in a custom appointment dialog (RadScheduleView) but I can't seem to figure out how to pre-populate the existing attendees (AssignedAttendees collection). ItemSource is working fine for selecting new entries. I've currently got this:

<telerik:RadAutoCompleteBox x:Name="_PeoplePicker"
     ItemsSource="{Binding Occurrence.Appointment.AvailableAttendees}"
     SelectedItems="{Binding Occurrence.Appointment.AssignedAttendees, Mode=TwoWay}"
     DisplayMemberPath="FullName"
     WatermarkContent="Type names..."/>

Am I binding to the wrong property?

4 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 05 Sep 2013, 03:23 PM
Hello Art,

Setting the SelectedItems property should do the trick. I've tried to reproduce the problem, but on my side everything works as expected. You can find my test application as attachment. Could you verify that it is working on your side and also that the AssignedAttendees collection in your code has items?

I'm looking forward to hearing from you.

Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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
Art Kedzierski
Top achievements
Rank 2
answered on 05 Sep 2013, 04:32 PM
I built a test app this morning as well and it works as expected. I've debugged the existing project and the AssignedAttendees collection is populating as expected. This is the code that populates the collections:

public void Appointment_Editing(object sender, AppointmentEditingEventArgs e)
{
    GLMAppointment editAppt = e.Appointment as GLMAppointment;
 
    // Populate AvailableAttendees and AvailableDevices lookups
    editAppt.AvailableAttendees = new ObservableCollection<Attendee>(this.Users);
    editAppt.AvailableDevices = new ObservableCollection<Device>(this.Equipment.Where(w => w.LocationFK == this.CurrentEquipment.LocationFK));
 
    // Load existing attendee(s) and device(s)
    using (Appt2UserRepository repository = RepositoryFactory.Instance.CreateAppt2UserRepository())
    {
        repository.GetAttendeesByAppt(new Guid(this.CurrentAppointment.UniqueId), (appt2userE) =>
        {
            editAppt.AssignedAttendees = new ObservableCollection<Attendee>();
            foreach (Appt2Attendee a in appt2userE)
            {
                editAppt.AssignedAttendees.Add(a.Attendee);
            }
        });
    }
    using (Appt2DeviceRepository repository = RepositoryFactory.Instance.CreateAppt2DeviceRepository())
    {
        repository.GetEquipmentByAppt(new Guid(this.CurrentAppointment.UniqueId), (appt2deviceE) =>
        {
            editAppt.AssignedDevices = new ObservableCollection<Device>();
            foreach (Appt2Device d in appt2deviceE)
            {
                editAppt.AssignedDevices.Add(d.Device);
            }
        });
    }
}

The AssignedDevices collection, populated in the exact same manner as AssignedDevices, appears just fine in the RadListBox it is bound to. I've manually cleaned and rebuilt to no avail. Oddly, I've thrown a RadListBox in the dialog and likewise bound it to AssignedDevices but it isn't populating either. trying to hunt down why the collection isn't making it to the control now.


0
Art Kedzierski
Top achievements
Rank 2
answered on 05 Sep 2013, 06:16 PM
I've changed 
editAppt.AssignedAttendees.Add(a.Attendee);

to
editAppt.AssignedAttendees.Add(this.Users.Where(w => w.UserName == a.UserName).FirstOrDefault());

And it works. No idea why. The exact same methodology (assigning the object via the relationship) works fine for AssignedDevices. And its not like AssignedAttendees didn't have Attendee objects in it the other way.

Ugh.
0
Accepted
Rosen Vladimirov
Telerik team
answered on 10 Sep 2013, 11:16 AM
Hello Art,

I cannot be sure what's causing the difference - maybe the objects are different and the comparison doesn't match in the first case. Anyway I'm glad you have found a solution.

Feel free to contact us in case you have any other problems or concerns.

Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
Tags
AutoCompleteBox
Asked by
Art Kedzierski
Top achievements
Rank 2
Answers by
Rosen Vladimirov
Telerik team
Art Kedzierski
Top achievements
Rank 2
Share this question
or