In this tutorial we are going to see how to use a Share Status task in Windows Phone development. Share Status Task is one of the Launcher task available from a list of task provided inbuilt to have a unique look and feel for the applications developed with Windows Phone 7. With this task we provide an option to share a status message to the social networking media of the user’s choice. Let use see the steps on how to use this task to share a status message to the social network. [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 share a message to the social networking media.
Now drag and drop few controls to the screen which is used to get the message from the end user and trigger an event to share the message using the Share Message Task as shown in the screen below.
Now we need to write our code in the button click event to get the user entered message to share it to the social networking media. To do that just go to the code behind and first add the USING handler code as shown in the code below.
using Microsoft.Phone.Tasks;
Next is to add the below code to the button click event which basically creates an instance of the ShareStatus task and show the option to share the message to the social network as shown in the code below.
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 F5DebugHowto9
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
ShareStatusTask ssTask = new ShareStatusTask();
ssTask.Status = textBox1.Text.ToString();
ssTask.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 with the outputs expected as shown in the screens below.
In real device we can see the option to share the message to the different social media over the fly like facebook, twitter, linkedin etc. So in this short tutorial we have seen how to use the share status task and the code which shares a message to the different social networking media. I am waiting to test over the applications on to the real device, mostly probably will be doing that in a couple of weeks. We will see another short tutorial pretty soon meanwhile Happy Programming!!!