This is a migrated thread and some comments may be shown as answers.

xml databinding

3 Answers 43 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 26 May 2009, 09:09 AM
Hi

Do I need to convert my xml datasource to a collection before binding to the radpanelbar or can I bind direct to an xml file?
If I can bind directly please advise how.

Many thanks.

3 Answers, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 1
answered on 26 May 2009, 10:47 AM
I found some example (based on treeview) to help me with this and implemented as shown, but the RadPanelBar is empty
Can someone atleast give me an idea of what I'm doing wrong?

Thanks.

xml datasource:
<?xml version="1.0" encoding="utf-8" ?> 
<Reports filepath="C:\Temp\ReportManagerPrototypeDemo\">    
  <Category Name="Sales">  
    <Report Name="SalesOctober08" description="Monthly Sales Analysis Report" read="true" created="01/10/2008" received="05/10/2008" lastedited="n/a" filename="SalesOctober2008.xps"></Report> 
    <Report Name="SalesNovember08" description="Monthly Sales Analysis Report" read="true" created="01/11/2008" received="10/11/2008" lastedited="10/11/2008" filename="SalesNovember2008.xps"></Report> 
    <Report Name="SalesDecember08" description="Monthly Sales Analysis Report" read="true" created="01/12/2008" received="05/12/2008" lastedited="n/a" filename="SalesDecember2008.xps"></Report> 
    <Report Name="SalesJanuary09" description="Monthly Sales Analysis Report" read="false" created="04/01/2009" received="06/01/2009" lastedited="n/a" filename="SalesJanuary2009.xps"></Report> 
  </Category> 
  <Category> 
    <Report Name="MarketingJanuary09" description="Monthly Marketing News" read="false" created="10/01/2009" received="11/01/2009" lastedited="12/01/2009" filename="MarketingJanuary2009.xps"></Report> 
    <Report Name="MarketingFebruary09" description="Monthly Marketing News" read="true" created="04/02/2009" received="07/02/2009" lastedited="n/a" filename="MarketingFebruary2009.xps"></Report> 
    <Report Name="MarketingMarch09" description="Monthly Marketing News" read="true" created="01/03/2009" received="03/03/2009" lastedited="13/03/2009" filename="MarketingMarch09.xps"></Report> 
    <Report Name="MarketingApril09" description="Monthly Marketing News" read="false" created="04/04/2009" received="06/04/2009" lastedited="n/a" filename="MarketingApril09.xps"></Report> 
  </Category> 
  <Category> 
    <Report Name="CompanyNewsApril09" description="Monthly Company News" read="true" created="04/04/2009" received="06/04/2009" lastedited="n/a" filename="CompanyNewsApril2009"></Report> 
    <Report Name="CompanyNewsNovember08" description="Monthly Company News" read="true" created="04/11/2008" received="11/11/2009" lastedited="n/a" filename="CompanyNewsNovember2008.xps"></Report> 
    <Report Name="CompanyNewsDecember2008" description="Monthly Company News" read="true" created="04/12/2008" received="08/12/2009" lastedited="n/a" filename="CompanyNewsDecember2008.xps"></Report> 
  </Category> 
</Reports> 
 

XAML code:

<Grid> 
        <Grid.Resources> 
            <XmlDataProvider x:Key="reportData" XPath="/Reports" Source="/reportdata.xml"></XmlDataProvider> 
            <HierarchicalDataTemplate DataType="Category" ItemsSource="{Binding XPath=Report}">  
                <StackPanel Orientation="Horizontal" MouseLeftButtonDown="StackPanel_MouseLeftButtonDown">  
                    <TextBlock FontWeight="Bold" Text="{Binding XPath=@Name}"></TextBlock> 
                </StackPanel> 
            </HierarchicalDataTemplate> 
            <DataTemplate DataType="Report">  
                <TextBlock Text="{Binding XPath=@Name}"></TextBlock>                  
            </DataTemplate> 
        </Grid.Resources> 
          
            <StackPanel>                  
                <my:RadPanelBar HorizontalAlignment="Left" Margin="0,0,0,357" Name="radPanelBar1" ExpandMode="Single"   
                                Width="270" ItemsSource="{Binding Source={StaticResource reportData}, XPath=Reports}">  
                </my:RadPanelBar> 
            </StackPanel> 
          
</Grid> 




0
Dimitrina
Telerik team
answered on 28 May 2009, 03:28 PM
Hi Ryan,

Thank you for your feedback. You can see a sample in the attached file.

Best wishes,
Dimitrina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dimitrina
Telerik team
answered on 28 May 2009, 03:34 PM
Hello Ryan,

We forgot to attach the file. You can find it attached to this post.

Also, you can read more information on this page http://blogs.telerik.com/valentinstoychev/posts/08-08-05/How_to_Databind_RadTreeView_in_WPF.aspx

Greetings,
Dimitrina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
PanelBar
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or