c# - Binding nested JSON to listbox in XAML -


this modal,

 public class main     {         public list<categories> categorieslist { get; set; }     }      public class categories     {         public int categoryid { get; set; }         public string categoryname { get; set; }         public list<pdf> pdfdocs { get; set; }         public list<video> videofiles { get; set; }     }      public class pdf     {         public string url { get; set; }         public string language { get; set; }         public string createddate { get; set; }         public bool isfavorite { get; set; }         public bool isread { get; set; }     } 

im using json.net deserialize

 main mainobj = jsonconvert.deserializeobject<main>(app.hello); 

i need display list of pdf's selected category, im using linq filter particular category, unable bind pdf list..

 pdf.itemssource = app.mainobj.categorieslist.where(i => i.categoryid.equals(s));    <listbox x:name="pdf" margin="0,0,0,363"  itemssource="{binding}" foreground="white">                 <listbox.itemtemplate>                     <datatemplate>                         <stackpanel>                             <textblock text="{binding pdf.url}" foreground="white"></textblock>                         </stackpanel>                     </datatemplate>                 </listbox.itemtemplate>             </listbox> 

<listbox itemssource="{binding categorieslist}">     <listbox.itemtemplate>         <datatemplate>             <stackpanel>                 <textblock text="{binding categoryid }" fontsize="20" />                  <itemscontrol itemssource="{binding pdf}" margin="0 20 0 0">                     <itemscontrol.itemtemplate>                         <datatemplate>                             <border borderbrush="blue" borderthickness="2">                                 <textblock text="{binding url }" fontsize="20" />                             </border>                         </datatemplate>                     </itemscontrol.itemtemplate>                 </itemscontrol>                 <itemscontrol itemssource="{binding videofiles}" margin="0 20 0 0">                     <itemscontrol.itemtemplate>                         <datatemplate>                             <border borderbrush="red" borderthickness="2">                                 <textblock text="{binding url}" fontsize="20" />                             </border>                         </datatemplate>                     </itemscontrol.itemtemplate>                 </itemscontrol>             </stackpanel>         </datatemplate>     </listbox.itemtemplate> 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -