Tweeter search application with Silverlight (Beginners) your first Silverlight application

Developers who are new to Silverlight or in learning phase this demo/article can help them creating a small application. This isn't just a hello world application this something interesting more than that. So ready to get your hand dirty with some XAML code and little bit power of Silverlight.

To create a Silverlight project you should have Silverlight library component installed on your computer. If you have visual studio 2010 installed then you are good to go as Silverlight 3.0 project template can be found there.
  1. Open a new project -> and select the Silverlight application from the Silverlight template.

  2. Now when you click OK you'll see the next window prompting you few more details about what kinda project you want to run your Silverlight application with in:

Leave the default selections and click OK.

Now you'll see two projects in your solution explorer.


Let go to our MainPage.xaml file to create some UI for our application. Add a Button and Listbox will create a UI and XAML like this. Set the Name and Content properties for your convenience.

<UserControl x:Class="TweeterSilverlightSearch.MainPage" xmlns="" xmlns:x="" xmlns:d="" xmlns:mc="" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
Button Content="Get Tweets" Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="btn_GetTweets" VerticalAlignment="Top" Width="75" Click="btn_GetTweets_Click" />
ListBox Height="247" HorizontalAlignment="Left" Margin="12,41,0,0" Name="TweetList" VerticalAlignment="Top" Width="376" />
 This mark up is your MainPage.xaml file. Now let write something in button click event of GetTweets button.
private void btn_GetTweets_Click(object sender, RoutedEventArgs e)
WebClient client = newWebClient();
//This event will let us know about the downloading competion
/*Experts prefer not to create seperate event handler for one time event handling they
             * prefer to have Anonymous handler using delegates and lambda expressions.
             * for e.g.
             * client.DownloadStringCompleted += (s, ea) => { System.Diagnostics.Debug.WriteLine(ea.Result); };
             * no need to write a seperate lines for writing handler code and it'll reduce the lines of code and increase
             * the code beauty as you can see.
             * */
            client.DownloadStringCompleted += newDownloadStringCompletedEventHandler(client_DownloadStringCompleted);
//Let's do our main job            client.DownloadStringAsync(newUri(""));
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)