WP7 Silverlight出现错误-“”匹配委托没有超载

问题描述 投票:0回答:1

我是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
                           };
        }
    }
}
silverlight windows-phone-7 twitter overloading
1个回答
1
投票

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

void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)

请注意,它是DownloadStringCompletedEventArgs而不是DownloadStringCompletedEventHandler

请参见本教程中的图像:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly93ZWJsb2dzLmFzcC5uZXQvvmmvv33vc2NvdHRndS9pbWFnZV90aHVtYl80RkZFM0VFRi5wbalt>

© www.soinside.com 2019 - 2024. All rights reserved.