WP7 Silverlight 错误 - “” 没有过载比赛代表
我是 WP7 编程新手,我一直在关注本教程
但是我已经跑了陷入许多错误,我想知道是否有人可以告诉我原因。我已经一遍又一遍地检查代码,据我所知,它都是正确的。
第一个问题是:
“twitter_DownloadsStringCompleted”没有重载与委托 system.net.downloadStringEventHandler 匹配
以下是代码:
private void button2_Click(object sender, RoutedEventArgs e)
{
WebClient twitter = new WebClient();
twitter.DownloadStringCompleted += new DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);
twitter.DownloadStringAsync(new Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=" + username.Text));
}
void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventHandler e)
{
throw new NotImplementedException();
}
public class TwitterItem
{
public string UserName { get; set; }
public string Message { get; set; }
public string ImageSource { get; set; }
}
void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventHandler e)
{
if (e.Error != null)
return;
XElement xmlTweets = XElement.Parse(e.Result);
listBox1.ItemsSource = from tweet in xmlTweets.Descendants("status")
select new TwitterItem
{
ImageSource = tweet.Elemend("user").Element("profile_image_url").Value,
Message = tweet.Element("text").Value,
UserName = tweet.Element("user").Element("SCreen_name").Value
};
}
}
}
I am new to WP7 programming and I have been following this tutorial
However I have run into a number of errors and I was wondering if anyone could tell me why. I have been over and over the code and as far as I can see it is all correct.
The first issue is a:
No overload for "twitter_DownloadsStringCompleted" matches delegate system.net.downloadStringEventHandler
Here is the code:
private void button2_Click(object sender, RoutedEventArgs e)
{
WebClient twitter = new WebClient();
twitter.DownloadStringCompleted += new DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);
twitter.DownloadStringAsync(new Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=" + username.Text));
}
void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventHandler e)
{
throw new NotImplementedException();
}
public class TwitterItem
{
public string UserName { get; set; }
public string Message { get; set; }
public string ImageSource { get; set; }
}
void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventHandler e)
{
if (e.Error != null)
return;
XElement xmlTweets = XElement.Parse(e.Result);
listBox1.ItemsSource = from tweet in xmlTweets.Descendants("status")
select new TwitterItem
{
ImageSource = tweet.Elemend("user").Element("profile_image_url").Value,
Message = tweet.Element("text").Value,
UserName = tweet.Element("user").Element("SCreen_name").Value
};
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已完成事件处理程序的参数列表应为:
注意它是
DownloadStringCompletedEventArgs
而不是DownloadStringCompletedEventHandler
。请参阅教程中的此图片:
The argument list for your completed event handler should be:
note it's
DownloadStringCompletedEventArgs
notDownloadStringCompletedEventHandler
.See this image from the tutorial: