Figure 2 shows the structure of the Tailspin Surveys mobile client application in more detail. For clarity, the diagram does not show all the links between all the components. In particular, multiple links exist between the model components and the view model and the application services, but showing all of these would unnecessarily clutter the diagram.
To understand how Tailspin built the UI components (such as the SurveyListView page and the AppSettingsView page), how the navigation between the pages work, and how the application determines which page to display to the user when the user launches the application, you should read the section, “The Design of the User Interface”
To understand how and why Tailspin uses the MVVM pattern, you should read the section, “Using the Model-View-ViewModel Pattern,” later in this chapter. This section explains the roles of the view, view model, and model components and how they are linked together, including the role of the ViewModelLocator class. This section also
describes some data binding scenarios in the application, including the way the application uses the Pivot control on the SurveyListView page and the Panorama control on the TakeSurveyView page.
Note: An application is tombstoned by the Windows Phone 7 device when, for example, the user navigates to another application or answers a call while using the application. The application should preserve any state it needs to return to the correct state when it is reactivated.
The developers at Tailspin use a dependency injection container to manage the instantiation of many of the classes, including the view model classes, in the application.
Tailspin uses the Funq dependency injection container (available at http://funq.codeplex.com/) instead of the Unity Application Block (Unity) because Unity requires the ability to emit Microsoft intermediate language (MSIL) code, which is not currently possible on the Windows Phone 7 platform. The Funq dependency injection container is also lightweight and fast.
The ContainerLocator class shows how the application creates the registrations and mappings in the Funq dependency injection container. In the Tailspin mobile client application, the ViewModel Locator instantiates the ContainerLocator object and is the only class in the application that holds a reference to a ContainerLocator object.
By default, the Funq dependency injection container registers instances as shared components. This means that the container will cache the instance on behalf of the application.
The Contents of the TailSpin.PhoneClient Project
The TailSpin.PhoneClient project organizes the source code and other resources into folders. The following table outlines what is contained in each folder and provides references to where this guide describes the content in more detail.
The Design of the User Interface
The Tailspin Surveys mobile client application follows the UI design guidance published in the UI Design and Interaction Guide for Windows Phone 7, which you can download from the Microsoft Download Center (http://go.microsoft.com/fwlink/?LinkID=183218).
This section describes how users navigate between the different pages of the mobile application and outlines the controls that Tailspin uses in the UI of the mobile client application.