Hierarchical Xml Templates : XmlDataProvider « Windows Presentation Foundation « C# / CSharp Tutorial






<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Authors and Their Books">
    <Page.Resources>
        <XmlDataProvider x:Key="data" XPath="Authors">
            <x:XData>
                <Authors xmlns="">
                    <Author Name="Jane Austen">
                        <BirthDate>1972</BirthDate>
                        <DeathDate>2010</DeathDate>
                        <Books>
                            <Book Title="A">
                                <PubDate>2003</PubDate>
                            </Book>
                            <Book Title="B">
                                <PubDate>1813</PubDate>
                            </Book>
                        </Books>
                    </Author>
                </Authors>
            </x:XData>
        </XmlDataProvider>
        <HierarchicalDataTemplate DataType="Author" ItemsSource="{Binding XPath=Books/Book}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding XPath=@Name}" />
                <TextBlock Text=" (" />
                <TextBlock Text="{Binding XPath=BirthDate}" />
                <TextBlock Text="-" />
                <TextBlock Text="{Binding XPath=DeathDate}" />
                <TextBlock Text=")" />
            </StackPanel>
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate DataType="Book">
            <StackPanel Orientation="Horizontal" TextBlock.FontSize="10pt">
                <TextBlock Text="{Binding XPath=@Title}" />
                <TextBlock Text="{Binding XPath=PubDate}" />
            </StackPanel>
        </HierarchicalDataTemplate>
    </Page.Resources>
    <TreeView ItemsSource="{Binding Source={StaticResource data}, XPath=Author}" />
</Page>
WPF Hierarchical Xml Templates








24.149.XmlDataProvider
24.149.1.HierarchicalDataTemplate and XmlDataProviderHierarchicalDataTemplate and XmlDataProvider
24.149.2.Xmldata island.xamlXmldata island.xaml
24.149.3.Hierarchical Xml TemplatesHierarchical Xml Templates
24.149.4.Using XmlDataProviderUsing XmlDataProvider
24.149.5.XmlDataProvider and static Xml resourceXmlDataProvider and static Xml resource
24.149.6.Retrieve data from XmlDataProvider with XPathRetrieve data from XmlDataProvider with XPath
24.149.7.XmlDataProvider and XmlNamespaceMappingXmlDataProvider and XmlNamespaceMapping
24.149.8.XmlDataProvider and ItemsControlXmlDataProvider and ItemsControl
24.149.9.Hyperlink and xpath filter for XmlDataProviderHyperlink and xpath filter for XmlDataProvider
24.149.10.Load XmlDocument to XmlDataProviderLoad XmlDocument to XmlDataProvider
24.149.11.Get XmlElement from Bounded viewGet XmlElement from Bounded view