Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not able to get an idea of what the expected output should be ? Can you draw the tree and post it. </p> <p>You may have to create a wrapper VM type for the domain type you want to present. say.. MasterPartVM. You can now define a property with the logic for the 2 routes e.g. Children. Your hierararchical data template will always expand the next level using this property. </p> <p>This will put the onus of finding the right children on your implementation of MasterPartVM.Children - which you seem to have nailed down. Let me know if I have misunderstood the problem.. </p> <p>e.g. In the linked post, you can see that I used a wrapper property to combine Subgroups and Entries to collate a single list.</p> <p>Here's another example</p> <pre><code>public class MyPart { public string Name { get; set; } public bool IsRoot { get; set; } public string[] ChildNames { get; set; } public IList&lt;MyPart&gt; Children { get { if (IsRoot) return ChildNames.Select(c =&gt; new MyPart { Name = c, ChildNames =new[]{c} }).ToList(); else return new List&lt;MyPart&gt;{new MyPart { Name = "No more children" }}; } } } MyPartsCollection = new ObservableCollection&lt;MyPart&gt;(); MyPartsCollection.Add(new MyPart { Name = "Root1", IsRoot = true, ChildNames = new []{"Item1", "Item2", "Item3"} }); </code></pre> <pre><code>&lt;TreeView ItemsSource="{Binding MyPartsCollection}"&gt; &lt;TreeView.ItemTemplate&gt; &lt;HierarchicalDataTemplate DataType="{x:Type local:MyPart}" ItemsSource="{Binding Children}"&gt; &lt;TextBlock Text="{Binding Name}" /&gt; &lt;/HierarchicalDataTemplate&gt; &lt;/TreeView.ItemTemplate&gt; &lt;/TreeView&gt; </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.
 

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