C#
25
Вклад в тег
<ListBox ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate DataType="local:Line">
<TextBlock Text="{Binding Title}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
public MainWindow()
{
InitializeComponent();
var lines = new List<Line>();
lines.Add(new Line() { Title = "1" });
lines.Add(new Line() { Title = "2" });
lines.Add(new Line() { Title = "3" });
this.DataContext = lines;
}
public class Line
{
public string Title { get; set; }
}
var pageNodes = document.DocumentNode.SelectNodes("//div[@id=\"pagination_related\"]//a");
if (pageNodes != null)
{
foreach (var node in pageNodes)
pages.Add(new Uri(this.Uri + node.Attributes[0].Value));
pages = pages.Distinct().ToList();
}
var chapterNodes = document.DocumentNode.SelectNodes("//div[@class=\"related_info\"]");
if (chapterNodes != null)
{
foreach (var node in chapterNodes)
{
var link = node.SelectSingleNode(".//h2//a");
var desc = node.SelectSingleNode(".//div[@class=\"related_tag_list\"]");
chapters.Add(new Chapter(new Uri(this.Uri, link.Attributes[0].Value), desc.InnerText));
}
}