Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Databinding more complex XML Structure
    primarykey
    data
    text
    <p>I asked this question already at the Microsoft forums, but no answer until now. I am stuck here. I have a quite nested xml snippet, which i like to bind via hierarchical Data templates.</p> <p>Here is the xml snippet:</p> <pre><code>&lt;project&gt; &lt;products&gt; &lt;product name="Product2" foldername="string" dbkey="-2405" dbtable="string"&gt; &lt;inifiles&gt; &lt;inifile name="string" dbkey="-3083" dbtable="string"&gt; &lt;sections&gt; &lt;section name="string" dbkey="-3025" dbtable="string"&gt; &lt;inientries&gt; &lt;inikey name="string" value="string" dbkey="9739" dbtable="string" /&gt; &lt;/inientries&gt; &lt;/section&gt; &lt;/sections&gt; &lt;/inifile&gt; &lt;/inifiles&gt; &lt;subproducts&gt; &lt;subproduct dbkey="1644" dbtable="string" name="Subproduct1"&gt; &lt;inifiles&gt; &lt;inifile name="string" dbkey="-6544" dbtable="string"&gt; &lt;sections&gt; &lt;section name="string" dbkey="2436" dbtable="string"&gt; &lt;inientries&gt; &lt;inikey name="string" value="string" dbkey="-2122" dbtable="string" /&gt; &lt;/inientries&gt; &lt;/section&gt; &lt;/sections&gt; &lt;/inifile&gt; &lt;/inifiles&gt; &lt;/subproduct&gt; &lt;subproduct dbkey="-4746" dbtable="string" name="Subproduct2"&gt; &lt;subinifiles&gt; &lt;subinifile name="string" dbkey="7519" dbtable="string"&gt; &lt;subsections&gt; &lt;subsection name="string" dbkey="1680" dbtable="string"&gt; &lt;subinientries&gt; &lt;subinikey name="string" value="string" dbkey="3682" dbtable="string" /&gt; &lt;/subinientries&gt; &lt;/subsection&gt; &lt;/subsections&gt; &lt;/subinifile&gt; &lt;/subinifiles&gt; &lt;/subproduct&gt; &lt;/subproducts&gt; &lt;/product&gt; `&lt;/products&gt; &lt;/project&gt; </code></pre> <p>My Hierarchical Datatemplates look like this:</p> <pre><code>&lt;HierarchicalDataTemplate DataType="product" ItemsSource="{Binding XPath=inifiles/inifile}" &gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Width="16" Height="16" Source="Images/gnome-applications.png"/&gt; &lt;TextBlock Text="{Binding XPath=@name}" FontWeight="bold"/&gt; &lt;/StackPanel&gt; &lt;/HierarchicalDataTemplate&gt; &lt;!-- ######################### Ini-Files ######################################### --&gt; &lt;HierarchicalDataTemplate DataType="inifile" ItemsSource="{Binding XPath=sections/section}" x:Name="inifile" &gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Width="16" Height="16" Source="Images/advanced.png"/&gt; &lt;TextBlock Text="{Binding XPath=@name}"&gt; &lt;TextBlock.ContextMenu&gt; &lt;ContextMenu&gt; &lt;Menu BorderThickness="3"&gt; &lt;MenuItem Header="{Binding XPath=@name}"&gt; &lt;MenuItem Header="_Find in Database"/&gt; &lt;MenuItem Header="_Edit" Tag="{Binding XPath=@value}"/&gt; &lt;/MenuItem&gt; &lt;/Menu&gt; &lt;/ContextMenu&gt; &lt;/TextBlock.ContextMenu&gt; &lt;/TextBlock&gt; &lt;TextBlock Text="{Binding XPath=@key}"/&gt; &lt;/StackPanel&gt; &lt;/HierarchicalDataTemplate&gt; &lt;!-- ######################### Sections ######################################### --&gt; &lt;HierarchicalDataTemplate DataType="section" ItemsSource="{Binding XPath=inientries/inikey}"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Width="16" Height="16" Source="Images/indent.png"/&gt; &lt;TextBlock Text="{Binding XPath=@name}"&gt; &lt;TextBlock.ContextMenu&gt; &lt;ContextMenu&gt; &lt;Menu&gt; &lt;MenuItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" Width="Auto" Header="{Binding XPath=@name}"&gt; &lt;MenuItem Header="_Find in Database"/&gt; &lt;MenuItem Header="_Edit" Tag="{Binding XPath=@value}"/&gt; &lt;/MenuItem&gt; &lt;/Menu&gt; &lt;/ContextMenu&gt; &lt;/TextBlock.ContextMenu&gt; &lt;/TextBlock&gt; &lt;TextBlock Text="{Binding XPath=@key}"/&gt; &lt;/StackPanel&gt; &lt;/HierarchicalDataTemplate&gt; &lt;!-- ######################### Ini-Keys ######################################### --&gt; &lt;HierarchicalDataTemplate DataType="inikey"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Width="16" Height="16" Source="Images/keyring.png"/&gt; &lt;TextBlock Text="{Binding XPath=@name}"&gt; &lt;TextBlock.ContextMenu&gt; &lt;ContextMenu&gt; &lt;Menu&gt; &lt;MenuItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" Width="Auto" Header="{Binding XPath=@name}"&gt; &lt;MenuItem Header="_Find in Database"/&gt; &lt;MenuItem Header="_Edit" Tag="{Binding XPath=@value}" /&gt; &lt;/MenuItem&gt; &lt;/Menu&gt; &lt;/ContextMenu&gt; &lt;/TextBlock.ContextMenu&gt; &lt;/TextBlock&gt; &lt;TextBlock Text="{Binding XPath=@value}"/&gt; &lt;/StackPanel&gt; &lt;/HierarchicalDataTemplate&gt; </code></pre> <p>I can bind to all tags except for the <code>&lt;subproducts&gt;</code> tag. I could read the structure through an XmlDocument, but i would lose all the advantages of the templates.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload