Introduction

This article walks you through the steps for creating and read settings in your Windows Phone application. On this demo, we will use IsolatedStorage to store and retrieve data on the application.Below are the steps

Create Windows Phone Application

  • Open Visual Studio 2013 and create a new project of type Windows Phone App.
  • On this project I create a solution called WindowsPhoneIsolatedStorage.  

  • After project creation, we need to implement the design. On this example, we need two textboxes and two buttons. A textbox to enter de setting and another one to enter the value of that setting. The buttons, will be used to save and read the settings information.

 

Save/Read Settings Implementation

 

private void Save_Click(object sender, RoutedEventArgs e) 
        
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; 
               
            if (!settings.Contains(txtSettings.Text)) 
            
                settings.Add(txtSettings.Text, txtValue.Text); 
            
            else 
            
                settings[txtSettings.Text] = txtValue.Text; 
            
            settings.Save(); 
   
        }
 
 
private void Read_Click(object sender, RoutedEventArgs e) 
        
            if (IsolatedStorageSettings.ApplicationSettings.Contains(txtSettings.Text)) 
            
                txtValue.Text = IsolatedStorageSettings.ApplicationSettings[txtSettings.Text].ToString(); 
            
   
        }

 

Run Application

Press F5 and check the result of the implementation. If you save a setting called "database" with value demo, and then remove the value and try to read the setting, the demo value will be displayed on the screen.

 

Windows Phone 8 Resources

See Also

Another important place to find a huge amount of Windows Phone related articles is the TechNet Wiki itself. The best entry point is Windows Phone Resources on the TechNet Wiki.