The first step in creating a Settings page for your Windows Phone app is to create a class to hold your settings and to save and load your settings from the local folder. For more information about how to store settings in key-value pairs in the local folder, see IsolatedStorageSettings. For more information about data storage in general, see Data for Windows Phone 8.

The class will contain a method to add or update a value in the local folder. In the following code, it is called AddOrUpdateValue. There is also a method to read a value or assign a default value if the setting has never been set. In the following code, it is called GetValueOrDefault.

For each setting or property, there are accessor functions. The following code contains several, called CheckBoxSetting, ListBoxSetting, and PasswordSetting. You can add your own properties by adding in your own accessor functions. For each setting, there is a string constant that defines the key name, and a constant that defines the default value.

For pages that do not require the user to press a confirmation button, you can use data binding to make the settings changes effective immediately and save the values in the local folder. All changes are made in the XAML for the settings page. Note that the data-binding mode of TwoWay makes the changes effective immediately.

Start by adding the xmlns:local="clr-namespace:SettingsSample" namespace declaration to the phone:PhoneApplicationPage element of your page. The following code shows the namespace declaration from the SettingsWithoutConfirmation.xaml page.

Settings that require text input, such as a username or password, may require the user to press a confirmation button when input has been completed. For Settings pages like these, you can add an app bar to the constructor to add the OK and Cancel buttons to the page.

For pages that require the user to press a confirmation button, you can use one-way data binding to load the current value, but any changes that the user makes are not effective immediately.

Start by adding the xmlns:local="clr-namespace:SettingsSample" namespace declaration to the phone:PhoneApplicationPage element of your page. The following code shows the namespace declaration from the SettingsWithConfirmation.xaml page.