This project is read-only.

The Fuel Tracker application is a fuel-efficiency calculator designed to demonstrate several concepts in Silverlight for phone application development. The application includes three pages that are bound to two entity types as follows:

· The CarInfoPage contains data-entry controls bound to the Name, InitialOdometerReading, and Picture properties of a Car object.

· The FillupPage contains data-entry controls bound to the FuelQuantity, OdometerReading, and PricePerFuelUnit properties of a Fillup object. Additionally, the page contains display-only controls bound to Car.Name and Car.Picture.

· The FillupInfoPage displays the results of the fuel-efficiency calculation, and contains controls bound to the previously-mentioned Car properties and to the Car.FillupHistory property, which holds a collection of Fillup objects.


Although this application is relatively simple, its requirements are just complex enough to warrant some infrastructure layers and separation of concerns. Some of these requirements are:

· Retrieving the data at application launch and displaying it in the user interface (UI).

· Saving and restoring the UI state during application deactivation and reactivation.

· Validating the data entry and saving the data to isolated storage.

An application is launched when the user taps its application icon. Deactivation occurs when an application is interrupted, and reactivation occurs when the interruption ends. This can happen in the following situations:

· The phone goes to sleep. Reactivation occurs when the user wakes the phone.

· A phone call is received. Reactivation occurs when the phone call ends.

· The user presses the Start or Search button. Reactivation occurs when the user returns to the application by pressing the Back button one or more times.

· The application invokes an external application task. Reactivation occurs when the user completes the task.

Application launch and reactivation involve loading the application into memory, causing an unavoidable delay before it is available for interaction. It is important to minimize this delay, so any code that you place in the PhoneApplicationService.Launching and Activated events should not include time-consuming operations.

Applications can retrieve saved data from isolated storage. However, accessing isolated storage is a time-consuming operation. Therefore, it should occur in the OnNavigatedTo method overrides of individual pages instead of Launching or Activated event handlers. Deactivation is usually temporary, so it is better to store UI state in memory for faster retrieval upon reactivation. This storage normally takes place in OnNavigatedFrom method overrides of individual pages, and retrieval takes place in OnNavigatedTo overrides.

In the Fuel Tracker application, each page displays data from a single Car, which the application must retrieve from isolated storage. However, this retrieval should occur only once when the OnNavigatedTo method of the first-loaded page is called.

One possible solution is to implement a static App.Car property that retrieves the car data from isolated storage the first time its getter is called. However, each page has its own additional initialization requirements that depend on the car data being present.

[more to come...]

Last edited Dec 16, 2010 at 8:38 PM by mparsons, version 2


No comments yet.