WP7 Silverlight 错误 - “” 没有过载比赛代表

发布于 2024-11-18 14:55:19 字数 1838 浏览 3 评论 0原文

我是 WP7 编程新手,我一直在关注本教程

http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx

但是我已经跑了陷入许多错误,我想知道是否有人可以告诉我原因。我已经一遍又一遍地检查代码,据我所知,它都是正确的。

第一个问题是:

“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

http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-11-25 14:55:19

已完成事件处理程序的参数列表应为:

void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)

注意它是 DownloadStringCompletedEventArgs 而不是 DownloadStringCompletedEventHandler

请参阅教程中的此图片:

教程中的屏幕截图

The argument list for your completed event handler should be:

void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)

note it's DownloadStringCompletedEventArgs not DownloadStringCompletedEventHandler.

See this image from the tutorial:

screen shot from tutorial

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文