Finally Silverlight 4 RC is released and also that Windows 7 Phone Series will rely heavily on Silverlight platform for apps platform. its a really good news for Silverlight developers and designers. More information on this here. You can use SL 4 RC with VS 2010. SL 4 RC does not come with VS 2010, you need to download it separately and install it. So for the next part, be ready with VS 2010 and SL4 RC, we will start using them and not betas.

With this momentum, let us go to the next part of our twitter client tutorial. This tutorial will cover setting your status in Twitter and also retrieving your

1) As everything in Silverlight is asynchronous, we need to have some visual representation showing that something is going on in the background. So what I did was to create a progress bar with indeterminate animation. The XAML is here below.

2) I will be toggling this progress bar to show the background work. So I thought of writing this small method, which I use to toggle the visibility of this progress bar. Just pass a bool to this method and this will toggle it based on its current visibility status.

publicvoid toggleProgressBar(bool Option)

{

if (Option)

{

if (progressBar1.Visibility == System.Windows.Visibility.Collapsed)

progressBar1.Visibility = System.Windows.Visibility.Visible;

}

else

{

if (progressBar1.Visibility == System.Windows.Visibility.Visible)

progressBar1.Visibility = System.Windows.Visibility.Collapsed;

}

}

3) Now let us create a grid to hold a textbox and a update button. The XAML will look like something below

5) In the above code, we have a event handler which will be fired on this request is completed – !! Remember SL is Asynch !! So in the myService_UploadStringCompleted, we will just toggle the progress bar and change some status text to say that its done. The code for this will be StatusMessage is just another textblock conveniently positioned in the page.

6) Now let us look at fetching the friends updates of the logged in user and displaying it in a datagrid. So just define a data grid and set its autogenerate columns as true.

7) Let us first create a data structure for use with fetching the friends timeline. The code is something like below:

namespace MaxTwitter.Classes

{

publicclass Status

{

public Status() {}

publicstring ID { get; set; }

publicstring Text { get; set; }

publicstring Source { get; set; }

publicstring UserID { get; set; }

publicstring UserName { get; set; }

}

}

You can add as many fields as you want, for the list of fields, have a look at here. It will ask for your Twitter username and password, just provide them and this will display the xml file. Go through them pick and choose your desired fields and include in your Data Structure.

8) Now the web client request for this is similar to the one we saw in step 4. Just change the uri in the last but one step to

https://twitter.com/statuses/friends_timeline.xml

Be sure to change the event handler to something else and within that we will use XLINQ to fetch the required details for us. Now let us how this event handler fetches details.

publicvoid parseXML(string text)

{

XDocument xdoc;

if(text.Length> 0)

xdoc = XDocument.Parse(text);

else

xdoc = XDocument.Parse(@"I USED MY OWN LOCAL COPY OF XML FILE HERE FOR OFFLINE TESTING");

in the event handler, we call this method with e.Result.ToString() Parsing XML files using LINQ is super cool, I love it.

I am stopping it here for this post. Will post the completed files in next post, as I’ve worked on a few more features in this page and don’t want to confuse you. See you soon in my next post where will play with Twitter lists. Have a nice day!