Pre-populate values in AutoCompleteTextBox

5 posts, 1 answers
  1. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 04 Sep 2013 Link to this post

    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?
  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 05 Sep 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 05 Sep 2013 Link to this post

    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.


  5. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 05 Sep 2013 Link to this post

    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.
  6. Answer
    Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 10 Sep 2013 Link to this post

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