c# - ListBox - Windows Store Application -


i not able listbox display result, using "nameinput.text," have no idea how work within foreach, can help?

c# code:

xdocument xdoc = xdocument.load("biblia.xml");  var pais =      pai in xdoc.descendants("b")     (string)pai.attribute("indice") == selectedindex.tostring()     select new     {         filho = pai.descendants("c")     };  foreach (var pai in pais) {     foreach (var filho in pai.filho) {         nameinput.text = nameinput.text + "     " + filho.attribute("n");     } } 

xaml:

<listbox x:name="listbox2">     <listbox.itemtemplate>         <datatemplate>             <stackpanel margin="10" >                 <textblock text="{binding filho}"/>             </stackpanel>         </datatemplate>     </listbox.itemtemplate> </listbox> 

edit: here part of xml

xml:

<?xml version="1.0" encoding="utf-8"?> <bible>   <b n="gênesis" indice="1">     <c n="1">       <v n="1"></v>       <v n="2"></v>     </c>     <c n="2">       <v n="1"></v>       <v n="2"></v>     </c>   <b n="Êxodo" indice="2">     <c n="1">       <v n="1"></v>       <v n="2"></v>     </c>     <c n="2">       <v n="1"></v>       <v n="2"></v>     </c>   </b> </bible> 

edit thought solution create list:

list<string> mylist = new list<string>();  foreach (var pai in pais) {     foreach (var filho in pai.filho) {         mylist.add(filho.attribute("n").value);     } } listboxteste1.itemssource = mylist; 


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -