This is driving me absolutely nuts.
I've got a WPF browser application that is somewhat like a content management system. We're going to use it for internal employees to get troubleshooting documentation. It consists of a Treeview, to hold all the topics, and a documentviewer control to display XPS documents.
Currently, I have XML that looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<TopicsList>
<Product>
<name>SR-650-101</name>
<type>
<name>Cannot pass POST</name>
<document>somefile1.xps</document>
</type>
<type>
<name>Serial # shows 12345</name>
<document>somedocument2.xps</document>
</type>
</Product>
<Product>
<name>TAV-PDK</name>
<type>
<name>C17200</name>
<document>somefile.xps</document>
</type>
</Product>
</TopicsList>
I've got the treeview control to successfully read the xml file, using the following XAML:
<Page.Resources>
<HierarchicalDataTemplate DataType="Product" ItemsSource="{Binding XPath=type}">
<TextBlock FontWeight="Bold" FontSize="12" Text="{Binding XPath=name}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="type">
<TextBlock Text="{Binding XPath=name}" />
</DataTemplate>
<XmlDataProvider x:Key="TopicsList" Source="topics.xml" XPath="TopicsList" />
</Page.Resources>
and then the treeview being defined as:
<TreeView Margin="0,20,0,0" Name="TreeView1" ItemsSource="{Binding Source={StaticResource TopicsList}, XPath=child::*}" SelectedItemChanged="OnNewNodeSelected" />
Like I said, it correctly lists my "Table of Contents" just fine, so this gets me 95% there. What I'm trying to figure out now, and can't for the life of me, is how to I get it so that when a user clicks a subject in the tree, it will go and get the node from the xml file and use it to load into the documentviewer?
Like I said, everything else so far works great, just cannot find anything online on how to get this to load. I did find something that looks like it would've worked perfectly if I was using a listbox, here however nothing seems to work so far in WPF with the treeview, and I'm just asking for one tiny little thing.
Can anyone help?
Thanks in advance!