How can you Add Network Connection Settings Page in your WP7 Application?
Do you want to integrate the network connection settings page (like: Airplane, Bluetooth, Cellular and/or WiFi) in your Windows Phone 7 application? Then this article will help you step-by-step to understand and integrate it.
Connection Settings page are those, where you can configure your connection types and various parameters of the connection. Windows Phone 7 SDK exposes the APIs for you to integrate them in your application. In this tutorial, we will discuss about these with a nice demo. Read further to know about these settings page and integration steps to the application.
Create Demo UI
Let us create the UI design of our demo application, where we will have 4 buttons (as shown in the figure below).
The four buttons will open up settings page for Airplane mode, Bluetooth mode, Cellular mode and WiFi mode respectively. We will also register the click event for each button, so that we can handle respective click events to open up proper settings page easily. Here is our sample XAML code, where we placed the four buttons: ![]() | ![]() |
Once our main demo page is ready, we can go further with the API calls to bring up the settings page. Continue reading on this topic.
Know About the APIs
Before going to the depth, we need to know about the APIs first. The namespace “Microsoft.Phone.Tasks” has one sealed class named “ConnectionSettingsTask” and one enumerator called “ConnectionSettingsType”. ConnectionSettingsTask has a property called ConnectionSettingsType and a method called Show().
You need to set proper connection type in the ConnectionSettingsType property to open up the respective settings page. The Show() method of the class ConnectionSettingsTask opens the proper page in the UI.
Have a look into the API declaration below:
namespace Microsoft.Phone.Tasks
{
public sealed class ConnectionSettingsTask
{
public ConnectionSettingsTask();
public ConnectionSettingsType ConnectionSettingsType { get; set; }
public void Show();
}
public enum ConnectionSettingsType
{
WiFi = 0,
Bluetooth = 1,
Cellular = 2,
AirplaneMode = 3,
}
}
In the above code snippet, you will easily understand that, we have 4 different connection types in Windows Phone 7 and they are: Wi-Fi, Bluetooth, Cellular and Airplane. Each settings page has different contents based on the connection properties. We will demonstrate these in the next point.
Playing with the Code to open Settings page
Now, it’s time for us to write code to open up the settings page of each connection type. How many lines of code do you expect to show the settings page? Remember, we didn’t create any XAML UI for the settings page. So what to do? Don’t worry, we don’t have to create any UI for each page. The API exposes everything for you. Just write 2-3 lines of code and you are done with that. When you call the Show() method, it will open the respective settings page. Let’s have a look into the below points to activate the settings page for each connection type:
Airplane Settings To activate the Airplane settings page, you need to create the instance of the task called “ConnectionSettingsTask” and then assign the ConnectionSettingsType to “AirplaneMode”. This will make sure that the proper settings page open up in the screen, when you call the Show() method of the ConnectionSettingsTask. Here is the code snippet for you: ![]() |
![]() |
Bluetooth Settings
To activate the Airplane settings page, you need to create the instance of the task called “ConnectionSettingsTask” and then assign the ConnectionSettingsType to “Bluetooth”. This will make sure that the proper settings page open up in the screen, when you call the Show() method of the ConnectionSettingsTask. Here is the code snippet for you: ![]() |
![]() |
Cellular Settings
To activate the Airplane settings page, you need to create the instance of the task called “ConnectionSettingsTask” and then assign the ConnectionSettingsType to “Cellular”. This will make sure that the proper settings page open up in the screen, when you call the Show() method of the ConnectionSettingsTask. Here is the code snippet for you: ![]() |
![]() |
Wi-Fi Settings
To activate the Airplane settings page, you need to create the instance of the task called “ConnectionSettingsTask” and then assign the ConnectionSettingsType to “WiFi”. This will make sure that the proper settings page open up in the screen, when you call the Show() method of the ConnectionSettingsTask. Here is the code snippet for you: ![]() |
![]() |
End Note
Hope this article will be helpful for you to understand the APIs to open up the settings page of each Connection settings task like WiFi, Cellular, Bluetooth and Airplane mode. You will be able to integrate those settings page just using 2-3 lines of code and the complete UI with all the options will be available in the screen.
Stay tuned to my blog (http://www.kunal-chowdhury.com) for more articles, tutorials and tips.
I am also available on Twitter @kunal2383 (http://twitter.com/kunal2383).
Like my Blog Page in Facebook (http://www.facebook.com/blog.kunal2383) to be updated.

Why not reach little more and connect with me directly on Twitter, Facebook and LinkedIn. I would love to hear your thoughts and opinions.