In this tutorial we are going to see how to play around with the ConnectionSettings Launcher task with Windows Phone 7 Development. The Connection Setting Launcher task is one of the few Launchers available with Windows Phone to provide a unique user experience across the application in windows phone. With ConnectionSettings task we can provide an option to the end user to manage the network connection settings on the device with ease. The network configuration settings involved are Bluetooth, Wifi, Airplane mode and Cellular. Let us see the steps on how to use the ConnectionSettings task in Windows phone development scenarios. [more]
Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below. Once the project is created add some controls which are used to trigger the Connection Settings Task as shown in the screen below.
Now drag and drop few controls to the screen which is used to trigger event that launches the Connection Settings Task with the required connection specified by the end user. Once we designed the screen with the controls we can see the screen looks like below.
Now we need to write our code in the button click event to trigger the Web Browser task on the user click. To do that just go to the code behind and first add the USING handler code on top with the existing using statements as shown in the code below.
using Microsoft.Phone.Tasks;
Next is to add the below code to the button click event, basically we have 4 different button events to handle different connection settings on different options available. Just copy and paste the code below as shown.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
namespace F5DebugHowto12
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.AirplaneMode;
connectionSettingsTask.Show();
}
private void button2_Click(object sender, RoutedEventArgs e)
{
ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
connectionSettingsTask.Show();
}
private void button3_Click(object sender, RoutedEventArgs e)
{
ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Cellular;
connectionSettingsTask.Show();
}
private void button4_Click(object sender, RoutedEventArgs e)
{
ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
connectionSettingsTask.Show();
}
}
}
Now we are done with our code, just run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected outputs as shown in the screens below.
Output Screens:
So in this tutorial we have seen how to make use of the connection settings task to handle the network connection or the other connections on the device. That’s it from this short tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!
No Comments
I'm on business lolita ls models nymph Maria Ozawa is not full on white. She is half Japanese and half Canadian. So shes only half white.
I need to to thank you for this very good read!! I definitely enjoyed every little bit of it. I've got you book marked to look at new things you post��|