In Part 1 and Part 2 of the series, we’ve started creating an app that tracks appointments using Everlive as it’s backend storage mechanism and uses the Telerik Cloud components. So far, we have examined the following controls: RadCloudLogin with SocialSharing via Facebook, RadCloudRegistration and the RadCloudCalendar control. Today, we will extend the Appointment.xaml page by adding a list of appointments for the current day using RadDataBoundListBox. We will also take a look at what is involved in retrieving data from Everlive as well as adding logout functionality to the app.
We’ll begin by creating a new Folder in our project called, “Helper”. Right click the “Helper” folder and create a new class called “TimeHeaderConverter.cs”. Paste the following snippet inside the class overriding the constructor:
As you can see from looking at the sample, this is going to be a ValueConverter to convert a DateTime value to a ShortTime string. So instead of saying, “12/17/2013 11:00AM”, it will return “11:00AM”.
This will be extremely valuable when we begin to display our Appointment Times.
Heading back to our Appointment.xaml file, we will need to drop in the following snippet before the LayoutRoot is declared.
This will give us access to the converter anytime we need it. Which is coming up shortly!
Inside our content panel, under our RadCloudCalendar component add the following snippet.
We begin by using our RadDataBoundListBox control and setting several properties including the EmptyContent property. This will allow us to inform the user that no appointments are available for the current day.
An ItemTemplate is created next that will display a Rectangle to help separate the items and then we use three TextBlocks to display the StartDate, EndDate and Subject. You should note here that the Converter we created earlier is being used on StartDate and EndDate.
While we are here, we need a way for the user to log out once they have logged in. We are going to use a simple ApplicationBarMenuItem after the last Grid tag as shown below:
Just make sure you add this after the last </Grid> tag. We will also need to add the following code to Appointment.xaml.cs to resolve the event handler.
Let’s stop for a moment and take a look at our Visual Studio designer in Figure 1.
Figure 1: The Appointment.xaml page showing the RadDataBoundListBox control.
Heading back to the code-behind file, go ahead and paste the following snippet replacing what you had there before except the OnLogout_Click event.
Taking it from the top, we create an instance of EverliveAppointmentSource as we will be needing access to this class in other methods. We have left our Loaded event handler, except now it simply calls the DisplayAppointments method. This method will fetch new appointments with the start and end date that we specified. Since we only want the current date, we were able to simply use the DateTime class. After we have our appointments, we set the ItemSource to our RadDataBoundListBox by calling the GetAppointments method which create a collection of IAppointment objects. We can then examine that data and only display the appointments for the current date.
Finally, the OnNavigatedTo event will initialize the CloudAppointmentSource to be used.
If we launch the application and add several appointments to the same day, then we will see what is shown in Figure 2.
Figure 2: The Appointment.xaml page showing our appointments for the day.
We’ve extended our app by adding a list of appointments for the current day using RadDataBoundListBox. We also took a look at what is involved in retrieving data from Everlive as well as adding logout functionality to the app. But we aren’t done yet. We are going to use the built-in design templates and add in an “About” page, use another Cloud component as well as add in our new Dev Center Template.
Michael Crump is a Microsoft MVP, Pluralsight and MSDN author as well as an international speaker. He works at Telerik with a focus on everything mobile. You can follow him on Twitter at @mbcrump or keep up with his various blogs by visiting his Telerik Blog or his Personal Blog.
Subscribe to be the first to get our expert-written articles and tutorials for developers!