how to bind xml file in listbox?

samo_messaad

New Member
I have an xml file as shown:\[code\]<?xml version="1.0" encoding="utf-8"?><PhoneBook xmlns="http://tempuri.org/PhoneBook.xsd"><Person><PersonItem name="name1" famil="famil1"> <Numbers> <NumbersItem number="123456" /> <NumbersItem number="789100" /> </Numbers></PersonItem></Person><Person><PersonItem name="name2" famil="famil2"> <Numbers> <NumbersItem number="654321" /> <NumbersItem number="111213" /> </Numbers></PersonItem></Person></PhoneBook>\[/code\]I have successfully bound a listbox to this XML using the following:\[code\]Imports <xmlns:DaftarTelephone="http://tempuri.org/PhoneBook.xsd"> Dim xmlPhoneBook = XDocument.Load(CurDir() & "\PhoneBook.xml") Dim q = From el In xmlPhoneBook ...<PhoneBook:PersonItem> lst.ItemsSource = q 'my listbox\[/code\]Here's my XAML:\[code\] <Page.Resources> <DataTemplate x:Key="PersonItemTemplate"> <StackPanel> <TextBlock Text="{Binding Path=Attribute[famil].Value}"/> <TextBlock Text="{Binding Path=Attribute[name].Value}"/> <TextBlock Text="{Binding Path=Attribute[number].Value}"/> </StackPanel> </DataTemplate></Page.Resources><Grid x:Name="LayoutRoot" > <ListBox x:Name="lst" ItemsSource="{Binding}" ItemTemplate="{DynamicResource PersonItemTemplate}" /> </Grid>\[/code\]family and name is shown correctly. But numbers are not shown!!!
 
Back
Top