Chapter 12. Managing User Settings

In this lesson you will learn about managing user settings. You will add a settings page to your application, add a settings class to the settings page, and make reference to the settings page in the XAML. You will see how you can confirm user settings before saving them, as well as how to save and load user settings automatically.

ADDING USER SETTINGS TO YOUR APPLICATION

Adding support for settings is a three-step process. First you must add a settings page to your application. Then you add a settings class to that settings page. Finally, you need to create a reference to the settings page in the XAML of all pages that you want to have use that settings page.

Adding a Settings Class to the Setting Page

To get started adding user settings to your application, add a new class file to your application. After adding the new class file, add the following using references to the top of the class file:

using System.IO.IsolatedStorage;
using System.Diagnostics;
using System.Collections.Generic;

After adding these references you will be able to instantiate a new IsolatedStorageSettings object. Settings for Windows Phone 7 applications are held in key/value pairs in isolated storage, and the IsolatedStorageSettings object enables you to create new settings keys, get and set the key values, and delete settings when necessary. To instantiate a new IsolatedStorageSettings object, add the following code to the top of the class file:

IsolatedStorageSettings isolatedStore; ...

Get Windows® Phone 7 Application Development 24-Hour Trainer now with O’Reilly online learning.

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