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

Displaying phone's appointments

5 Answers 60 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 22 Apr 2013, 01:44 PM
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!

5 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 24 Apr 2013, 09:34 PM
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?

 

 

 

 



0
Todor
Telerik team
answered on 25 Apr 2013, 11:28 AM
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.
0
David
Top achievements
Rank 1
answered on 25 Apr 2013, 11:13 PM
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!
0
Todor
Telerik team
answered on 30 Apr 2013, 11:17 AM
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.
0
David
Top achievements
Rank 1
answered on 30 Apr 2013, 02:05 PM
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!
Tags
Calendar
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Todor
Telerik team
Share this question
or