February 2011 - Posts
Last week SELA conducted a LIVE interview with all of the speakers at SDP 2011 (Sela Developer Practice conference).

You can catch my interview on the new Sela College Channel:
http://www.sela.co.il/y/ArikSprint11
or on YouTube:
That’s me on the right :)
In my interview I talked about the presentation I’ll deliver on March 15 in the Client track on the topic WPF + Silverlight + Windows Phone 7 = 3-Screens Development where I’ll show how to develop an application to WPF, Silverlight and Windows Phone 7, while maintaining a single code base. Also I plan to show some Azure features.
Hurry up and register - Fun is guaranteed!
That’s it for now,
Arik Poznanski.
In the previous post we’ve seen how to get list of trends on twitter.
On this post we continue to explore twitter service. We will see you how to search for twits on twitter.

Searching Twitter
Twitter exposes a JSON-based search service in the following address:
http://search.twitter.com/search.json?q={0}
where {0} should be replaced with your search term.
The results are returned in JSON data format, so we will use again the DataContractJsonSerializer. For more details on how to use it, check out the previous post.
Defining Twit and TwitterResults
Similarly to what we’ve done in the previous post, we need to declare some C# model classes that will be used to parse the twitter JSON results.
/// <summary>
/// Model for twit
/// </summary>
public class Twit
{
/// <summary>
/// Gets or sets the text.
/// </summary>
/// <value>The text.</value>
public string text { get; set; }
/// <summary>
/// Gets the decoded text.
/// </summary>
/// <value>The decoded text.</value>
public string DecodedText
{
get
{
return HttpUtility.HtmlDecode(text);
}
}
/// <summary>
/// Gets or sets the from_user.
/// </summary>
/// <value>The from_user.</value>
public string from_user { get; set; }
/// <summary>
/// Gets or sets the profile_image_url.
/// </summary>
/// <value>The profile_image_url.</value>
public string profile_image_url { get; set; }
/// <summary>
/// Gets or sets the created_at.
/// </summary>
/// <value>The created_at.</value>
public DateTime created_at { get; set; }
}
/// <summary>
/// Model for twitter results
/// </summary>
public class TwitterResults
{
/// <summary>
/// Gets or sets the results.
/// </summary>
/// <value>The results.</value>
public Twit[] results { get; set; }
}
Note that the twit text should be html-decoded before using it, so I’ve added a DecodedText property to do the job.
Implement the Twitter Search Service
We will implement a static method named TwitterService.Search that will receive the search term as its first parameter and a few delegates to allow our class to work asynchronously:
- Action<IEnumerable<Twit>> onSearchCompleted, which will be called when the twitter search is complete.
- Action<Exception> onError, which will be called if there is an error while searching twitter.
- Action onFinally, which will be called always, whether there was an exception or not. Think of it as the finally section on a common try-catch block.
So the method signature will be:
public static void Search(string searchText, Action<IEnumerable<Twit>> onSearchCompleted = null, Action<Exception> onError = null, Action onFinally = null)
To search twitter we will use the WebClient class, yet again:
WebClient webClient = new WebClient();
// register on download complete event
webClient.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
...
};
string encodedSearchText = HttpUtility.UrlEncode(searchText);
webClient.OpenReadAsync(new Uri(string.Format(TwitterSearchQuery, encodedSearchText)));
where TwitterSearchQuery is defined as follows:
private const string TwitterSearchQuery = "http://search.twitter.com/search.json?q={0}";
The rest of the code handles the different delegates: on SearchCompleted, onError, onFinally. I bring here the method in its full:
/// <summary>
/// Searches the specified search text.
/// </summary>
/// <param name="searchText">The search text.</param>
/// <param name="onSearchCompleted">The on search completed.</param>
/// <param name="onError">The on error.</param>
public static void Search(string searchText, Action<IEnumerable<Twit>> onSearchCompleted = null, Action<Exception> onError = null, Action onFinally = null)
{
WebClient webClient = new WebClient();
// register on download complete event
webClient.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
try
{
// report error
if (e.Error != null)
{
if (onError != null)
{
onError(e.Error);
}
return;
}
// convert json result to model
Stream stream = e.Result;
DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(TwitterResults));
TwitterResults twitterResults = (TwitterResults)dataContractJsonSerializer.ReadObject(stream);
// notify completed callback
if (onSearchCompleted != null)
{
onSearchCompleted(twitterResults.results);
}
}
finally
{
// notify finally callback
if (onFinally != null)
{
onFinally();
}
}
};
string encodedSearchText = HttpUtility.UrlEncode(searchText);
webClient.OpenReadAsync(new Uri(string.Format(TwitterSearchQuery, encodedSearchText)));
}
Using the Twitter Search Service
Using the service is easy:
TwitterService.Search(
textbox.Text,
(items) => { listbox.ItemsSource = items; },
(exception) => { MessageBox.Show(exception.Message); },
null
);
There is a sample application which can be downloaded here.
Note: this code was first published as part of the “Using Pivot and Panorama Controls” lab found in the Windows Phone Training Kit for Developers, which I wrote for Microsoft.
That’s it for now,
Arik Poznanski.
In this post I will show you how you can get the list of trends on twitter.
On the next post I’ll show you how you can get the twits related to these trends and generally search twitter for twits.

What The Trend?
Twitter provides a cool site named http://whatthetrend.com/ where you can see the 10 topics which are most discussed currently on twitter.
This site also provides us a web service that returns its results in JSON data format.
The service can be accessed using the following URL:
http://api.whatthetrend.com/api/v2/trends.json?api_key={0}
where {0} should be replaced with your generated application key.
Generate Application Key
Since the twitter trends service provider limits its access using an application key, you must create one.
To do this, go to the site http://api.whatthetrend.com/ , on the right side you have a section titles "Request API key". By filling a small form you can immediately get a free application key which you can use.
Parsing JSON Data
The data returned from http://whatthetrend.com/ is in JSON data format. We would like to parse this data and convert it to C# classes.
To do so, we will use the class DataContractJsonSerializer which resides in the assembly System.ServiceModel.Web.dll.
The first thing we need to do is to add a reference to this assembly.

The service returns following JSON formatted data:
{"api_version":"2.0","as_of":"2011-02-05 14:39:19","trends":[{"name":"#scariestwordsever","trend_id":"201146","url":"http:\/\/search.twitter.com\/search?q=%23scariestwordsever","category_id":"9","category_name":"Meme","query":"#scariestwordsever","description":{"created_at":"2011-02-04T09:05:27+00:00","blurb_id":"322542","text":"Users are tweeting words\/phrases that would be the scariest to ever hear.","score":"1"},"first_trended_at":"2011-02-04T05:27:55+00:00","last_trended_at":"2011-02-05T14:35:01+00:00","newly_trending":"0","trend_index":"2","locked":false},{"name":"#thebadbehaviourtour","trend_id":"201678","url":"http:\/\/search.twitter.com\/search?q=%23thebadbehaviourtour","category_id":"14","category_name":"Other","query":"#thebadbehaviourtour","description":{"created_at":"2011-02-05T11:56:09+00:00","blurb_id":"322813","text":"@PlanetJedward aka John and Edward have announced new tour dates! @planetJedward are reply to as many fans as they can who put #TheBadBehaviourtour.","score":"0"},"first_trended_at":"2011-02-05T09:18:50+00:00","last_trended_at":"2011-02-05T14:35:01+00:00","newly_trending":"0","trend_index":"3","locked":false},
...
]}
Yea, this looks scary, but I’ve highlighted the interesting parts.
What we have here is a structure that have the properties:
The type of the trends property is an array of structures, each has the following properties:
- name
- trend_id
- url
- category_id
- category_name
- query
- description
- first_trended_at
- last_trended_at
- newly_trending
- trend_index
- locked
The description property is itself a structure that has the following properties:
- created_at
- blurb_id
- text
- score
All we need to do to get this information in an easy C# way is to define model classes which will have the same properties.
/// <summary>
/// Model for twitter trend description
/// </summary>
public class TrendDescription
{
/// <summary>
/// Gets or sets the created_at.
/// </summary>
/// <value>The created_at.</value>
public DateTime created_at { get; set; }
/// <summary>
/// Gets or sets the text.
/// </summary>
/// <value>The text.</value>
public string text { get; set; }
/// <summary>
/// Gets or sets the score.
/// </summary>
/// <value>The score.</value>
public int score { get; set; }
}
/// <summary>
/// Model for twitter trend
/// </summary>
public class Trend
{
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <value>The description.</value>
public TrendDescription description { get; set; }
/// <summary>
/// Gets or sets the first_trended_at.
/// </summary>
/// <value>The first_trended_at.</value>
public DateTime first_trended_at { get; set; }
/// <summary>
/// Gets or sets the last_trended_at.
/// </summary>
/// <value>The last_trended_at.</value>
public DateTime last_trended_at { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string name { get; set; }
/// <summary>
/// Gets or sets the newly_trending.
/// </summary>
/// <value>The newly_trending.</value>
public int newly_trending { get; set; }
/// <summary>
/// Gets or sets the query.
/// </summary>
/// <value>The query.</value>
public string query { get; set; }
/// <summary>
/// Gets or sets the trend_index.
/// </summary>
/// <value>The trend_index.</value>
public int trend_index { get; set; }
/// <summary>
/// Gets or sets the URL.
/// </summary>
/// <value>The URL.</value>
public string url { get; set; }
/// <summary>
/// Gets or sets the category_id.
/// </summary>
/// <value>The category_id.</value>
public int category_id { get; set; }
/// <summary>
/// Gets or sets the category_name.
/// </summary>
/// <value>The category_name.</value>
public string category_name { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Trend"/> is locked.
/// </summary>
/// <value><c>true</c> if locked; otherwise, <c>false</c>.</value>
public bool locked { get; set; }
}
/// <summary>
/// Model for trends results
/// </summary>
public class TrendsResults
{
/// <summary>
/// Gets or sets the api_version.
/// </summary>
/// <value>The api_version.</value>
public string api_version { get; set; }
/// <summary>
/// Gets or sets the as_of.
/// </summary>
/// <value>The as_of.</value>
public DateTime as_of { get; set; }
/// <summary>
/// Gets or sets the trends.
/// </summary>
/// <value>The trends.</value>
public Trend[] trends { get; set; }
}
to parse the data into these objects we use the DataContractJsonSerializer:
DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(TrendsResults));
TrendsResults trendsResults = (TrendsResults)dataContractJsonSerializer.ReadObject(stream);
where stream is a Stream object which contains the data in JSON format.
Implement the Get Trends Service
Now that we know how to parse the results, lets wrap this all in a method.
Our GetTrends method will receive a few delegates as parameters to allow our class to work asynchronously:
- Action<IEnumerable<Trend>> onGetTrendsCompleted, which will be called when the trends are ready to be processed.
- Action<Exception> onError, which will be called if there is an error while getting the trends.
- Action onFinally, which will be called always, whether there was an exception or not. Think of it as the finally section on a common try-catch block.
So the method signature will be:
public static void GetTrends(Action<IEnumerable<Trend>> onGetTrendsCompleted = null, Action<Exception> onError = null, Action onFinally = null)
To get the trends we will use the WebClient class:
WebClient webClient = new WebClient();
// register on download complete event
webClient.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
...
};
webClient.OpenReadAsync(new Uri(string.Format(WhatTheTrendSearchQuery, WhatTheTrendApplicationKey)));
Where WhatTheTrendSearchQuery is defined as follows:
private const string WhatTheTrendSearchQuery = "http://api.whatthetrend.com/api/v2/trends.json?api_key={0}";
The rest of the code handles the different delegates: onGetTrendsCompleted, onError, onFinally. I bring here the method in its full:
/// <summary>
/// Gets the trends.
/// </summary>
/// <param name="onGetTrendsCompleted">The on get trends completed.</param>
/// <param name="onError">The on error.</param>
public static void GetTrends(Action<IEnumerable<Trend>> onGetTrendsCompleted = null, Action<Exception> onError = null, Action onFinally = null)
{
WebClient webClient = new WebClient();
// register on download complete event
webClient.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
try
{
// report error
if (e.Error != null)
{
if (onError != null)
{
onError(e.Error);
}
return;
}
// convert json result to model
Stream stream = e.Result;
DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(TrendsResults));
TrendsResults trendsResults = (TrendsResults)dataContractJsonSerializer.ReadObject(stream);
// notify completed callback
if (onGetTrendsCompleted != null)
{
onGetTrendsCompleted(trendsResults.trends);
}
}
finally
{
// notify finally callback
if (onFinally != null)
{
onFinally();
}
}
};
webClient.OpenReadAsync(new Uri(string.Format(WhatTheTrendSearchQuery, WhatTheTrendApplicationKey)));
}
Using the Twitter Trends Service
As usual, the end result is very easy to use, simply call TwitterService.GetTrends static method and pass a delegate for the “completed” notification.
TwitterService.GetTrends(
(items) => { listbox.ItemsSource = items; },
(exception) => { MessageBox.Show(exception.Message); },
null
);
There is a sample application which can be downloaded here.
Note: this code was first published as part of the “Using Pivot and Panorama Controls” lab found in the Windows Phone Training Kit for Developers, which I wrote for Microsoft.
That’s it for now,
Arik Poznanski.
Following is another utility class I wrote to help me search Digg results asynchronously on a Windows Phone 7 application.
I will present how it was written and then how to use it. At the end of this post you can find a sample application that contains all the code.

How to Search Digg?
Define DiggStory
First we define a model class that will hold a single Digg entry. This class will have the following properties:
- Title – title of the Digg entry
- Description – description of the Digg entry
- Link – link to the Digg entry
- Diggs – number of diggs in Digg
/// <summary>
/// Model for Digg Story
/// </summary>
public class DiggStory
{
/// <summary>
/// Initializes a new instance of the <see cref="DiggStory"/> class.
/// </summary>
/// <param name="title">The title.</param>
/// <param name="description">The description.</param>
/// <param name="link">The link.</param>
/// <param name="diggs">The diggs.</param>
public DiggStory(string title, string description, string link, int diggs)
{
Title = title;
Description = description;
Link = link;
Diggs = diggs;
}
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
public string Title { get; set; }
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <value>The description.</value>
public string Description { get; set; }
/// <summary>
/// Gets or sets the link.
/// </summary>
/// <value>The link.</value>
public string Link { get; set; }
/// <summary>
/// Gets or sets the diggs.
/// </summary>
/// <value>The diggs.</value>
public int Diggs { get; set; }
}
Add Assembly
In the following implementation I use Digg Search API which returns XML based results, so I‘m using LINQ to XML to easily parse the output.
In order to do so, we will add a reference to the assembly System.Xml.Linq.dll

Generate Application Key
Like most service providers, Digg also requires you to generate an application key for your application. This helps them know who uses their service and allow them to limit the requests from a single consumer.
I found the following application key to work, but I suggest you find a way to generate a new one in commercial apps.
private const string DiggApplicationKey = "http://www.myapp.com";
Implement the Digg Search Service
Querying the Digg service is rather easy. Just use the following link:
http://services.digg.com/search/stories?query={0}&appkey={1}
Where {0} should be replaced with your search term and {1} should be replace with your application key.
So our Search method will receive the search term as a parameter.
In addition, since we want our class to work asynchronously we will accept as parameters a few more delegates:
- Action<IEnumerable<DiggStory>> onSearchCompleted, which will be called when the Digg results are ready to be processed.
- Action<string, Exception> onError, which will be called if there is an error while searching Digg. The first parameter for the delegate is the search term and the second is the exception.
- Action onFinally, which will be called always, whether there was an exception or not. Think of it as the finally section on a common try-catch block.
So the method signature will be:
public static void Search(string searchText, Action<IEnumerable<DiggStory>> onSearchCompleted = null, Action<string, Exception> onError = null, Action onFinally = null)
To run the search we will use the WebClient class:
WebClient webClient = new WebClient();
// register on download complete event
webClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e)
{
...
};
// start search
webClient.DownloadStringAsync(new Uri(string.Format(DiggSearchQuery, searchText, DiggApplicationKey)));
where DiggSearchQuery is defined as follows:
private const string DiggSearchQuery = "http://services.digg.com/search/stories?query={0}&appkey={1}";
The result of the search is an XML string, so we use LINQ to XML to parse it:
// convert xml result to model
XElement storyXml = XElement.Parse(e.Result);
var stories = from story in storyXml.Descendants("story")
select new DiggStory(
story.Element("title").Value,
story.Element("description").Value,
story.Attribute("link").Value,
int.Parse(story.Attribute("diggs").Value));
The rest of the code handles the different delegates: onCompleted, onError, onFinally. I bring here the method in its full:
/// <summary>
/// Searches the specified search text.
/// </summary>
/// <param name="searchText">The search text.</param>
/// <param name="onSearchCompleted">The on search completed.</param>
/// <param name="onError">The on error.</param>
public static void Search(string searchText, Action<IEnumerable<DiggStory>> onSearchCompleted = null, Action<string, Exception> onError = null, Action onFinally = null)
{
WebClient webClient = new WebClient();
// register on download complete event
webClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e)
{
try
{
// report error
if (e.Error != null)
{
if (onError != null)
{
onError(searchText, e.Error);
}
return;
}
// convert xml result to model
XElement storyXml = XElement.Parse(e.Result);
var stories = from story in storyXml.Descendants("story")
select new DiggStory(
story.Element("title").Value,
story.Element("description").Value,
story.Attribute("link").Value,
int.Parse(story.Attribute("diggs").Value));
// notify completed callback
if (onSearchCompleted != null)
{
onSearchCompleted(stories);
}
}
finally
{
// notify finally callback
if (onFinally != null)
{
onFinally();
}
}
};
// start search
webClient.DownloadStringAsync(new Uri(string.Format(DiggSearchQuery, searchText, DiggApplicationKey)));
}
Using the Digg Search Service
Using the class is very easy, just pass the required search term and a delegate for the “completed” notification.
DiggService.Search(
textbox.Text,
(items) => { listbox.ItemsSource = items; },
(s, exception) => { MessageBox.Show("Search term " + s + " could not be found due to:\n" + exception.Message); },
null
);
There is a sample application which can be downloaded here.
Note: this code was first published as part of the “Using Pivot and Panorama Controls” lab found in the Windows Phone Training Kit for Developers, which I wrote for Microsoft.
That’s it for now,
Arik Poznanski.
Following is a utility class I wrote to help me read RSS items asynchronously on a Silverlight for Windows Phone 7 application.
I will present how it was written and then how to use it. At the end of this post you can find a sample application that contains all the code.
How to read RSS?
Add Helper Assembly
The first thing we need to do is to add a reference to the assembly, System.ServiceModel.Syndication.dll which contains classes that can parse RSS feeds.
This assembly is part of the Silverlight 3 SDK. It isn’t part of the Windows Phone 7 SDK, but there is no problem in using it there. You can find the file under:
%ProgramFiles%\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.ServiceModel.Syndication.dll

You will get the following warning, just ignore it, it works.

Define RssItem
Before we get to business, let’s define a model class that will encapsulate the data of a single RSS item.
Our RssItem class will hold the following properties: Title, Summary, PublishedDate and Url. In addition I provide a PlainSummary property that will hold a plain text version of the RSS item. Usually the summary has HTML tags that we just want to ignore, thus PlainSummary for the rescue.
/// <summary>
/// Model for RSS item
/// </summary>
public class RssItem
{
/// <summary>
/// Initializes a new instance of the <see cref="RssItem"/> class.
/// </summary>
/// <param name="title">The title.</param>
/// <param name="summary">The summary.</param>
/// <param name="publishedDate">The published date.</param>
/// <param name="url">The URL.</param>
public RssItem(string title, string summary, string publishedDate, string url)
{
Title = title;
Summary = summary;
PublishedDate = publishedDate;
Url = url;
// Get plain text from html
PlainSummary = HttpUtility.HtmlDecode(Regex.Replace(summary, "<[^>]+?>", ""));
}
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
public string Title { get; set; }
/// <summary>
/// Gets or sets the summary.
/// </summary>
/// <value>The summary.</value>
public string Summary { get; set; }
/// <summary>
/// Gets or sets the published date.
/// </summary>
/// <value>The published date.</value>
public string PublishedDate { get; set; }
/// <summary>
/// Gets or sets the URL.
/// </summary>
/// <value>The URL.</value>
public string Url { get; set; }
/// <summary>
/// Gets or sets the plain summary.
/// </summary>
/// <value>The plain summary.</value>
public string PlainSummary { get; set; }
}
Implement The RSS service
The RSS service will get the RSS feed URL as a parameter.
In addition, since we want our class to work asynchronously we will accept as parameters a few more delegates:
- Action<IEnumerable<RssItem>> onGetRssItemsCompleted, which will be called when the RSS items are ready to be processed.
- Action<Exception> onError, which will be called if there is an error while getting the RSS items.
- Action onFinally, which will be called always, whether there was an exception or not. Think of it as the finally section a common try-catch block.
So the method signature will be:
public static void GetRssItems(string rssFeed, Action<IEnumerable<RssItem>> onGetRssItemsCompleted = null, Action<Exception> onError = null, Action onFinally = null)
To get the feed XML we will use the WebClient class:
WebClient webClient = new WebClient();
// register on download complete event
webClient.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
...
};
webClient.OpenReadAsync(new Uri(rssFeed));
The actual RSS parsing is done using the SyndicationFeed class from our helper assembly:
// convert rss result to model
List<RssItem> rssItems = new List<RssItem>();
Stream stream = e.Result;
XmlReader response = XmlReader.Create(stream);
SyndicationFeed feeds = SyndicationFeed.Load(response);
foreach (SyndicationItem f in feeds.Items)
{
RssItem rssItem = new RssItem(f.Title.Text, f.Summary.Text, f.PublishDate.ToString(), f.Links[0].Uri.AbsoluteUri);
rssItems.Add(rssItem);
}
The rest of the code is for handling the different delegates: onCompleted, onError and onFinally. I bring here the method in its full:
/// <summary>
/// Gets the RSS items.
/// </summary>
/// <param name="rssFeed">The RSS feed.</param>
/// <param name="onGetRssItemsCompleted">The on get RSS items completed.</param>
/// <param name="onError">The on error.</param>
public static void GetRssItems(string rssFeed, Action<IEnumerable<RssItem>> onGetRssItemsCompleted = null, Action<Exception> onError = null, Action onFinally = null)
{
WebClient webClient = new WebClient();
// register on download complete event
webClient.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
try
{
// report error
if (e.Error != null)
{
if (onError != null)
{
onError(e.Error);
}
return;
}
// convert rss result to model
List<RssItem> rssItems = new List<RssItem>();
Stream stream = e.Result;
XmlReader response = XmlReader.Create(stream);
SyndicationFeed feeds = SyndicationFeed.Load(response);
foreach (SyndicationItem f in feeds.Items)
{
RssItem rssItem = new RssItem(f.Title.Text, f.Summary.Text, f.PublishDate.ToString(), f.Links[0].Uri.AbsoluteUri);
rssItems.Add(rssItem);
}
// notify completed callback
if (onGetRssItemsCompleted != null)
{
onGetRssItemsCompleted(rssItems);
}
}
finally
{
// notify finally callback
if (onFinally != null)
{
onFinally();
}
}
};
webClient.OpenReadAsync(new Uri(rssFeed));
}
Using the RSS Service
Using the class is very easy, just provide the URL as the first parameter and a delegate for getting the “completed” notification.
private void Button_Click(object sender, RoutedEventArgs e)
{
RssService.GetRssItems(
WindowsPhoneBlogPosts,
(items) => { listbox.ItemsSource = items; },
(exception) => { MessageBox.Show(exception.Message); },
null
);
}
There is a sample application which can be downloaded here.

Note: this code was first published as part of the “Using Pivot and Panorama Controls” lab found in the Windows Phone Training Kit for Developers, which I wrote for Microsoft.
That’s it for now,
Arik Poznanski.