Czesc mam plik xml w ktorym mam kilka ksiazek. Probuje zbindowac je do text block ale zadne dane nie sa wyswietlone. Wyswietlaja sie 4 boxy wiec wiem ze plik jest poprawnie widziany bo sa w nim 4 ksiazki. Jakies wskazowki ? Dzieki
XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<books>
<element>
<category>Thriller</category>
<description>In The Green Line, Abby Donovan's decade-long dream of partnership is now just months from fruition. But after a late-night train mishap drops her into a world of drugs, gangbangers, murder, and corruption, everything changes</description>
<id>1</id>
<image>images/greenLine.jpg</image>
<price>10.50</price>
<title>The Green Line</title>
</element>
<element>
<category>Comedy</category>
<description>In The Green Line, Abby Donovan's decade-long dream of partnership is now just months from fruition. But after a late-night train mishap drops her into a world of drugs, gangbangers, murder, and corruption, everything changes</description>
<id>1</id>
<image>images/greenLine.jpg</image>
<price>10.50</price>
<title>AAA</title>
</element>
<element>
<category>Thriller</category>
<description>In The Green Line, Abby Donovan's decade-long dream of partnership is now just months from fruition. But after a late-night train mishap drops her into a world of drugs, gangbangers, murder, and corruption, everything changes</description>
<id>1</id>
<image>images/greenLine.jpg</image>
<price>10.50</price>
<title>BBBB</title>
</element>
<element>
<category>Thriller</category>
<description>In The Green Line, Abby Donovan's decade-long dream of partnership is now just months from fruition. But after a late-night train mishap drops her into a world of drugs, gangbangers, murder, and corruption, everything changes</description>
<id>1</id>
<image>images/greenLine.jpg</image>
<price>10.50</price>
<title>The Green Line</title>
</element>
</books>
</root>
XAML:
<GridView x:Name="DataGrid1">
<GridView.ItemTemplate>
<DataTemplate>
<Grid Background="AliceBlue" Width="300" Height="200">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Title}"></TextBlock>
<TextBlock Text="{Binding Category}"></TextBlock>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
C#
string XMLPath = Path.Combine(Package.Current.InstalledLocation.Path, "booksData/data.xml");
XDocument loadedD = XDocument.Load(XMLPath);
var newData = from query in loadedD.Descendants("element")
select new Book
{
Title = (string)query.Attribute("title"),
Category = (string)query.Attribute("category")
};
DataGrid1.ItemsSource = newData;