我需要用我的 Xaml 绑定标题和链接,这是我的代码隐藏:
private void DownLoadCompleted(object sender, HtmlDocumentLoadCompleted e)
{
_popVideos = new List<PopularVideos>();
var imgs = e.Document.DocumentNode.SelectNodes(@"//img[@src]")
.Select(img => new
{
Link = img.Attributes["src"].Value,
Title = img.Attributes["alt"].Value,
}).ToList();
this.listBoxPopular.ItemsSource = imgs;
}
我的 Xaml 是这样的:
<ListBox Name="listBoxPopular">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Name="imagem" Source="{Binding Path=alt}"/>
<TextBlock Text="{Binding Path=Title}" Tap="HyperlinkButton_Tap" Tag="{Binding Path=Url}" FontSize="30" Foreground="#FF159DDE" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>