So far in this book, you've been working with sample applications that contain one main page. In almost every real-world phone application, however, you need support for more pages. The Windows Phone 7 platform provides the simple-to-use Navigation Framework for navigating between pages in your application. You need to become familiar with just two objects — NavigationContext and NavigationService — to support multiple pages in your applications.

Getting to Know the Navigation Framework

When you create a new Windows Phone 7 project, you are given a MainPage.xaml file to work with. When you open this file, at the top of the page you see a declaration for a PhoneApplicationPage object. Each page in your app is an instance of this class type. But behind the scenes, there's also an object called PhoneApplicationFrame. This frame object is responsible for holding and displaying pages in your app. As you make use of multiple pages in your application, the pages will be loaded and displayed in this underlying frame object. Figure 5-4 shows an example of the object hierarchy between the frame and page.

FIGURE 5-4: A navigation frame and page.


The NavigationService Class

The first class you should become familiar with when adding support for multiple pages in your app is NavigationService. This class provides several methods that enable you to switch the currently ...

Get Beginning Windows® Phone 7 Application Development: Building Windows® Phone Applications Using Silverlight® and XNA® now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.