XmlDataProvider binding

5 posts, 0 answers
  1. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 31 Aug 2010 Link to this post

    Hello,
    I can't figure out the binding to the HierarchicalDataTemplate.
    I'm able to populate the Childnodes fine., but no luck with the parentNodes

    Any thoughts would be great

    Regards,
    Rick Mueller
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
          
            <Table>
                <CompanyName>Digital Kitchen1</CompanyName>
                <Location>Eden Prairie1</Location>
                <ContactName>Rick Mueller</ContactName>
                <ContactTitle>PrepCook</ContactTitle>
                <EmpImage>male.jpg</EmpImage>
                <StDate>15664</StDate>
                <EmpId>156</EmpId>
            </Table>
            <Table>
                <CompanyName>Digital Kitchen</CompanyName>
                <Location>Eden Prairie</Location>
                <ContactName>Willie The Dog</ContactName>
                <ContactTitle>LineCook</ContactTitle>
                <EmpImage>male.jpg</EmpImage>
                <StDate>40535</StDate>
                <EmpId>156</EmpId>
            </Table>
        <Table>
                <CompanyName>Digital Kitchen</CompanyName>
                <Location>Eden Prairie</Location>
                <ContactName>Jose Sosa</ContactName>
                <ContactTitle>Dishwasher</ContactTitle>
                <EmpImage>male.jpg</EmpImage>
                <StDate>40535</StDate>
                <EmpId>156</EmpId>
            </Table>
            <Table>
                <CompanyName>Digital Kitchen</CompanyName>
                <Location>Eden Prairie</Location>
                <ContactName>Maria Anders</ContactName>
                <ContactTitle>BroilerCook</ContactTitle>
                <EmpImage>female.jpg</EmpImage>
                <StDate>40535</StDate>
                <EmpId>156</EmpId>
            </Table>
    </NewDataSet>
    <Window.Resources>
              
            <XmlDataProvider x:Key="Contact"
                Source="xmlData/Employee.xml"
                XPath="NewDataSet/Table"/>
              
        
      
            <HierarchicalDataTemplate 
                             x:Name="TreeData" 
                             DataType="XmlDataProvider"
                             ItemsSource="{Binding Contact}">
                 <TextBlock Text="{Binding XPath=ContactTitle}" 
                            Foreground="Black" 
                            FontWeight="Bold"
                            FontSize="15" />
            </HierarchicalDataTemplate>
              
                     <DataTemplate x:Key="Team">
                      <TextBlock Text="{Binding XPath=ContactName}" 
                               Foreground="Blue" 
                               FontWeight="Bold"
                               FontSize="9" />
                      </DataTemplate>
      
      
        </Window.Resources>
      
        <Grid>
            <telerik:RadTreeView 
                Height="311" HorizontalAlignment="Left" 
                Margin="320,0,0,0" Name="radTreeView1" 
                VerticalAlignment="Top" Width="183"
                ItemsSource="{Binding Source={StaticResource Contact},XPath=ContactTitle}"
                ItemTemplate="{StaticResource Team}"/>
    </Grid>
  2. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 31 Aug 2010 Link to this post

    Hello
    I was able to get a little closer, The Tree Populates the Headers with the right groups. But its populates "Table as the childnodes.

    Any Thoughts?

    <Window.Resources>
             
           <XmlDataProvider x:Key="Contact"
               Source="xmlData/Employee.xml"
               XPath="NewDataSet/Table"/>
           <CollectionViewSource x:Key="Employees"
               Source="{StaticResource Contact}">
               <CollectionViewSource.SortDescriptions>
                   <scm:SortDescription PropertyName="ContactTitle" Direction="Ascending" />
                   <scm:SortDescription PropertyName="ContactName"/>
                   </CollectionViewSource.SortDescriptions>
               <CollectionViewSource.GroupDescriptions>
                   <PropertyGroupDescription PropertyName="ContactTitle"/>
               </CollectionViewSource.GroupDescriptions>
           </CollectionViewSource>
           <HierarchicalDataTemplate x:Key="DataTemplate1" ItemsSource="{Binding Mode=OneWay, Source={StaticResource Employees}}">
               <Grid>
                  
                       <TextBlock x:Name="TileContent_Data"
                              FontSize="15"
                              Foreground="Black"
                              Background="Transparent"
                              Text="{Binding Name}" />
                  
               </Grid>
           </HierarchicalDataTemplate>
           <DataTemplate x:Key="template" >
                 
            
                   <TextBlock FontSize="13"
                          Foreground="Black"
                          Background="Transparent"
                          Text="{Binding XPath=ContactTitle}" />
                 
           </DataTemplate>
             
       </Window.Resources>
         
         
         
         
         
         
         
         
         
       <Grid Background="Transparent">
           <Grid  DataContext="{Binding Mode=OneWay, Source={StaticResource Employees}}">
               <telerik:RadTreeView
                     
               Height="289" HorizontalAlignment="Left" 
               Margin="321,0,0,22" Name="radTreeView1" Width="165"
                   ItemsSource="{Binding Groups}" ItemTemplate="{StaticResource DataTemplate1}">
            
               </telerik:RadTreeView>
           </Grid>

    Rick Mueller

  3. UI for WPF is Visual Studio 2017 Ready
  4. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 01 Sep 2010 Link to this post

    Hello,
    Any thoughts?
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Sep 2010 Link to this post

    Hi Rick Mueller,

    I am not entirely sure that i understand your scenario correctly. So I prepared a sample project illustrating three different scenarios.

    In the first RadTreeView in the example, the flat collection from the XML data source is simply displayed.

    the second RadTreeView in the example uses a modified XML datasource that represents a hierarchical collection and the RadTreeView displays it.

    The third RadTreeView uses the flat collection represented in XML document but sorting and grouping is applied on it. The RadTreeView displays the group names as a first-level nodes and the ContactNames for each group.

    Please take a look at the project and let me know if it helps. If, however, your scenario is different, please elaborate a bit more on it and we will gladly help you implement it.

    Sincerely yours,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 03 Sep 2010 Link to this post

    Hello Tina,
    Thank you for your examples. It was the right solution. The reason for my issues was the ItemTemplate was not in a HierarchicaData format 

    Thank you again for your help,

    Regards,
    Rick Mueller
Back to Top
UI for WPF is Visual Studio 2017 Ready