Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Complex Hierarchical data template
    primarykey
    data
    text
    <p>I'm looking at a complex structure and I can't seem to find a way to display it...</p> <p>My situation:</p> <p>Class: Milestone has 2 lists inside, a list of other submilestones and a list of activities.</p> <p>So structured could be like:</p> <p>M1</p> <ul> <li>Milestones <ul> <li>SubMilestone <ul> <li>Milestones</li> <li>Activities</li> </ul></li> <li>Submilestone</li> </ul></li> <li>Activities</li> </ul> <p>Anybody has any idea's on how to create this? or could boost me into a direction?</p> <p><strong>ANSWER to my problem</strong></p> <pre><code>&lt;TreeView ItemsSource="{Binding Path=Project.TrackList}"&gt; &lt;TreeView.Resources&gt; &lt;HierarchicalDataTemplate DataType="{x:Type deto:Track}" ItemsSource="{Binding Path=FaseList}"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="{Binding Path=TrackType}" /&gt; &lt;/StackPanel&gt; &lt;/HierarchicalDataTemplate&gt; &lt;HierarchicalDataTemplate DataType="{x:Type deto:Fase}" ItemsSource="{Binding Path=MilestoneList}"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="{Binding Path=FaseType}" /&gt; &lt;/StackPanel&gt; &lt;/HierarchicalDataTemplate&gt; &lt;HierarchicalDataTemplate DataType="{x:Type deto:Milestone}" ItemsSource="{Binding Converter={StaticResource MConverter}}"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="{Binding Path=Description}" /&gt; &lt;/StackPanel&gt; &lt;/HierarchicalDataTemplate&gt; &lt;HierarchicalDataTemplate DataType="{x:Type deto:Activity}" ItemsSource="{Binding Path=ActivityList}"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="{Binding Path=Description}" /&gt; &lt;/StackPanel&gt; &lt;/HierarchicalDataTemplate&gt; &lt;/TreeView.Resources&gt; &lt;/TreeView&gt; </code></pre> <p>And the converter:</p> <pre><code>public class MilestoneConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var m = value as Milestone; CompositeCollection collection = new CompositeCollection(); collection.Add(new CollectionContainer() { Collection = m.MilestoneList }); collection.Add(new CollectionContainer() { Collection = m.ActivityList }); return collection; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion } </code></pre>
    singulars
    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