如何使此列表與列表框綁定?我可以獲取我想要的數據,因爲當我放置一個斷點時,我發現它正在正確加載。我聽說他們有一個ObservableCollection,但不知道如何使用,然後不綁定xaml。ObservableCollection在C#中綁定Windows Phone
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;
}
我的類:
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; }
}
第一個想法 - 使課堂流行的視頻=>公共課熱門視頻 – jimpanzer
@jimpanzer把和不工作。 –