CHAPTER 5 EXERCISE SOLUTIONS

Exercise 1 Solution

The answer is a and c. When an application requires you to write custom data files to Isolated Storage, you should make use of the IsolatedStorageFile object. If your application only needs to quickly save objects in a name/value pair format, you can use the IsolatedStorageSettings object instead.

Exercise 2 Solution

False. When your application is first being run, it can run custom code in the Application_Launching event handler. When your application is in the running state, no separate event is fired. After the Launched event has been processed, your application is considered to be running, and you can add custom code to the Loaded event handlers of various pages in the application.

Exercise 3 Solution

Your application is free to use any available memory on the device. You can check to see how much memory is available by checking the AvailableFreeSpace property of the IsolatedStorageSettings.ApplicationSettings object. Of course, you shouldn't use all the available space on the device because there will most likely be additional applications that also have storage requirements. Using all the available free space is a good way to ensure that users uninstall your application.

Exercise 4 Solution

When a user navigates to a certain page in your application, you can override the OnNavigatedTo method to run custom code. Alternatively, when a user navigates away from that page, you can also run custom code by overriding the OnNavigatedFrom ...

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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.