25. Deleting with ItemSource set
http://stackoverflow.com/questions/6422378/listbox-operation-not-supported-on-read-only-collection
this.UserListBox.Items.RemoveAt(this.UserListBox.SelectedIndex);
33. WebClient
private void button2_Click(object sender, RoutedEventArgs e)
{
WebClient twitter = new WebClient();
// Handle downloaded data when finished
twitter.DownloadStringCompleted += new
DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);
// Set the site
twitter.DownloadStringAsync(new
Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=" + textBox1.Text));
}
34. WebClient
private void button2_Click(object sender, RoutedEventArgs e)
{
WebClient twitter = new WebClient();
// Handle downloaded data when finished
twitter.DownloadStringCompleted += new
DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);
// Set the site
twitter.DownloadStringAsync(new
Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=" + textBox1.Text));
}
35. WebClient
void twitter_DownloadStringCompleted(object sender,
DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
return;
XElement xmlTweets = XElement.Parse(e.Result);
lstTwitter.ItemsSource =
from tweet in xmlTweets.Descendants("status")
select new TwitterItem
{
ImageSource =
tweet.Element("user").Element("profile_image_url").Value,
Message = tweet.Element("text").Value
};
}