Welcome back again to the series on “Conference Buddy” an app being written in Windows Phone 8 as well as Windows 8, in this blog post we will continue our journey with the Windows Phone 8 version. Let’s take a look at what we have covered so far and what is coming up:
Just like last time, I’m going to assume your development environment is setup and RadControls for Windows Phone 8 is installed. If you don’t have them yet, you can download them from your account. The completed source code for the section can be found here.
Dynamic AppBars for Conference Buddy in Windows Phone 8.
We can see from the contact details page that we have been working with in the past two parts that our application will contain several pages of data as shown in Figure 1 (click to enlarge it).
Figure 1: Contact Collect Detail Screen Design
This part of the application has four “screens” or PivotItems of data. If we take a look at the application bar (in green at the bottom), then we will quickly notice the following:
We will quickly see that our standard application bar will not work and that we will need to dynamically load a new application bar as the user swipes to the next page.
At this point, we will need to take our existing RadDataForm and place it into the Pivot control. An example of how to do this is shown below.
We first make use of the Pivot Control and give it a Name, a Title and a SelectionChanged event, which we will tie in later. Then we declare our two PivotItems (contact details and interest). Note: We can add in subscriptions and request, but I just want you to understand the concept.
From here, we will make use of the PhoneApplicationPage.Resources and declare an appbar for both the Contact Details and Interest and assign them a name. You may put this at the top of the page before the Grid.
Note: If you don’t have the images, then simply download my project or add them through Blend. From here we can see the declarations for both ApplicationBars that will be shown dynamically as the user navigates through the different screens. I’ve added a MenuItem to the second one just to show you that you are not limited to IconButtons.
The only changes that I’m going to make it here is adding in the click event handlers for the “SelectionChanged” event on the Pivot.
We can see very quickly here that as the currently selected Pivotitem changes that this event will fire and check to see which index we are on and display the appropriate ApplicationBar.
We can now see this in action with the video integrated below:
In this article, we took a look at adding application bars dynamically in your Windows Phone 8 application. This is crucial to our Conference Buddy application as it is used in more than just the Contact Details page, but several others. You may also need this functionality in your own Windows Phone 8 app and I hope this helped show how easy it is to implement.
As always, the source code to this project is available here and if you have any questions, then just let me know.
I know I remind you every single post, but the Nokia premium developer program allows you to get RadControls for Windows Phone for free and they have a lot of additional resources to help you get started.
-Michael Crump (@mbcrump)
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!