c#Windows Phone中带绑定的可观察收集
如何使此列表与listbox绑定?我可以得到我想要的数据,因为当我放置一个断点时,我看到它被正确加载。我听说他们有一个可观的收集,但不知道如何使用,然后不绑定xamlc#Windows Phone中带绑定的可观察收集,c#,xaml,binding,windows-phone,observablecollection,C#,Xaml,Binding,Windows Phone,Observablecollection,如何使此列表与listbox绑定?我可以得到我想要的数据,因为当我放置一个断点时,我看到它被正确加载。我听说他们有一个可观的收集,但不知道如何使用,然后不绑定xaml private void DownLoadCompleted(object sender, HtmlDocumentLoadCompleted e) { _popVideos = new List<PopularVideos>(); var data =
private void DownLoadCompleted(object sender, HtmlDocumentLoadCompleted e)
{
_popVideos = new List<PopularVideos>();
var data = e.Document.DocumentNode.SelectSingleNode("//div[@class='content']")
.Descendants("img")
.Select(img => new
{
Title = img.Attributes["alt"].Value,
Url = img.Attributes["src"].Value,
}).ToList();
foreach (var item in data)
{
PopularVideos pop = new PopularVideos(item.Title, item.Url);
_popVideos.Add(new PopularVideos(item.Title, item.Url));
}
listBoxPopular.ItemsSource = _popVideos;
}
正如我在中提到的,有一篇介绍数据绑定的文章,您应该通过它来了解。一篇介绍性文章并没有包含我所需要的一切,所以我再次询问。第一个想法-使类成为PopularVideos=>public类PopularVideos@jimpanzer把它放进去,一直不工作。
class PopularVideos
{
public PopularVideos() { }
public PopularVideos(string titulo, string url)
{
Titulo = titulo;
BitmapImage Img = new BitmapImage(new Uri(url));
}
public string Titulo { get; set; }
public Uri Url { get; set; }
}