Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > TreeView > Binding Complex XML to TreeView

Not answered Binding Complex XML to TreeView

Feed from this thread
  • Prakash avatar

    Posted on Jan 4, 2012 (permalink)

    Hi,

    Telerik Version: 2010.2.924.1040

    Requirement: 

    I've a following XML and I want to bind that to RadTreeView, Please help me in doing this task. 

    I've seen the following link and found that XML nodes are of same type, XmlNodeItem, Items
    Whereas I need an example where the XML has different type of nodes at each level.

    http://www.telerik.com/help/silverlight/radtreeview-populating-with-data-data-binding-to-xml.html

    The following is sample XML, which is very close to my actual XML. I'm waiting for your response at the earliest. 

    <Channels>
           <Channel>
    <Name>STAR</Name>
    <Programmes>
                          <Program>
    <ProgramName>News</ProgramName>
    <ProgramID>Star001</ProgramID>
    <Duration>30M</Duration>
    <Advertisements>
                                                <Advertisement>
    <AdvertisementName>Advertisement 1</Advertisement>
     <Advertisement>
    <Advertisement>
                                                      <AdvertisementName>Advertisement 2</Advertisement>
                                                </Advertisement>
     </Advertisements>
    </Program>
                        <Program>
                                   <ProgramName>Movie</ProgramName>
                                   <ProgramID>Start002</ProgramID>
                                   <Duration>3H</Duration>
                                   <Advertisements>
    <Advertisement>
    <AdvertisementName>Advertisement 1</AdvertisementName>
    </Advertisement>
    </Advertisements>
                        </Program>
    </Programmes>
          </Channel>
           <Channel>
    .
    .
    .
    </Channel>
    </Channels>

    Thanks,
    Prakash.

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Jan 9, 2012 (permalink)

    Hi Prakash,

    Basically in order to display multiple child types in the RadTreeViewItems hierarchy, you need to make sure that they inherit one common type. Please note that you can only set one children collection as an ItemsSource in an HierarchicalDataTemplate for each RadTreeViewItem and this is why you need to define only one children collection for each item and populate it with all children items even if they are different.

    Please have a look at this forum thread where a similar scenario is described. The approach that is demonstrated there can be used along with the approach for displaying XML data in the RadTreeView (from the help article). Please give it a try and let me know if it helps.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > TreeView > Binding Complex XML to TreeView
Related resources for "Binding Complex XML to TreeView"

Silverlight TreeView Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]