Displaying phone's appointments

6 posts, 0 answers
  1. David
    David avatar
    15 posts
    Member since:
    Mar 2013

    Posted 22 Apr 2013 Link to this post

    The sample code for the Calendar control shows "made up" appointments.

    Are there any examples that use appointments that are already in the phone's calendar?

    Thanks!
  2. David
    David avatar
    15 posts
    Member since:
    Mar 2013

    Posted 24 Apr 2013 Link to this post

    OK - I tried modifying the sample app:  "RadControls for Windows Phone 8 Q1 2013"  to use live calendar data (I previously added appointments to the Emulator).

    In SampleAppointments.cs, I changed the FetchData function to the following:

    public override void FetchData(DateTime startDate, DateTime endDate)
     {
     
         this.AllAppointments.Clear();
     
         Appointments appts = new Appointments();
     
         //Identify the method that runs after the asynchronous search completes.
         appts.SearchCompleted += new EventHandler<AppointmentsSearchEventArgs>(Appointments_SearchCompleted);
     
         DateTime start = startDate;
         DateTime end = endDate;
         int max = 100;
     
         //Start the asynchronous search.
         appts.SearchAsync(start, end, max, "Appointments Test #1");
     
     }
     void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
     {
         foreach (Appointment appt in e.Results)
         {
             this.AllAppointments.Add(new SampleAppointment()
             {
                 StartDate = appt.StartTime,
                 EndDate = appt.EndTime,
                 Subject = appt.Subject,
                 Details = appt.Details,
                 Location = appt.Location
             });
     
         }
         this.OnDataLoaded();
     
     }

    Now, when the Calendar demo loads, it shows the appointments in the Calendar. However, when you click on a any day that has an appointment entry, instead of getting the appointment info below the calendar, it says there are no appointments for the selected day.

    Any suggestions?

     

     

     

     



  3. DevCraft banner
  4. Todor
    Admin
    Todor avatar
    778 posts

    Posted 25 Apr 2013 Link to this post

    Hi David,

    Thank you for contacting us.

    You should have in mind that the information about the appointments in our demo is displayed in an instance of RadDataBoundListBox and is not part of the RadCalendar instance. Since you have successfully loaded the appointments in the calendar, you just need to make sure that the same information goes to the list box as well. In the demo, we call the DisplayAppointmentsForDate method which takes the appointments from the appointments source. Since you load the appointment asynchronously, you need to make sure that when the search for appointments is completed, you update the ItemsSource of the list box as well.

    I hope this information helps. If you need further assistance, don't hesitate to write us back.

    Regards,
    Todor
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  5. David
    David avatar
    15 posts
    Member since:
    Mar 2013

    Posted 25 Apr 2013 Link to this post

    A couple of more questions:

    Where is AllAppointments defined and where are it's methods documented?

    It appears that my issue is due to the fact that I have to use async calls to get the phone's colander info. Any suggestions on how I can make it so that the RadDataBoundListBox gets updated AFTER the async call finishes? I assume this would be in my  Appointments_SearchCompleted routine?
    Thanks!
  6. Todor
    Admin
    Todor avatar
    778 posts

    Posted 30 Apr 2013 Link to this post

    Hi David,

    From what I see, the Appointments_SearchCompleted is inside your SampleAppointments class and the RadDataBoundListBox is on your MainPage, therefore it will be tricky to set the items for the list box from inside the appointments class. What you can do is subscribe for the DataLoaded event of your SampleAppointments instance and in the event handler get the appointments for the selected date by using the AppointmentsSource's GetAppointments method as shown in the RadCalendar's FirstLook example.

    I hope this information helps. If you need further assistance, don't hesitate to write us back.

    Regards,
    Todor
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  7. David
    David avatar
    15 posts
    Member since:
    Mar 2013

    Posted 30 Apr 2013 Link to this post

    I ended up stashing a pointer to the RadDataBoundListBox in a static public located in App. I did this in the RadDataBoundListBox's Loaded event. This allowed me to access the ListBox from the Appointments class.

    Then I moved loading the list box to the Appointments Search_Completed routine.

    It now works as intended.

    Thanks!
Back to Top
DevCraft banner