Note that there are some explanatory texts on larger screens.

plurals
  1. POHierarchicalDataTemplate and Many-To-Many with Payload Entities Navigation Binding Issue
    primarykey
    data
    text
    <p>I have two Many-To-Many with Payload entities as shown below: </p> <p><img src="https://i.stack.imgur.com/X3lFS.png" alt="Entity Snapshot"></p> <p>So, to make an <strong>Assembly</strong> stored in MasterPartNumber with a part number: <code>MasterPartNumber.pn</code>, I use the navigation property <code>ParentBOMs</code>, which is given by the relationship: <code>MasterPartNumber.pnID = MasterPartsList.parentPnID</code>. This gives me all the child pnIDs under that parent assembly. </p> <p>To get the <strong>child part numbers for that assembly</strong>, I use the <code>ChildPn</code> navigation property, defined by <code>MasterPartsList.pnID = MasterPartNumber.pnID</code>. </p> <p>Please note that top level assembly items are NOT listed in MasterPartsList (they would have a parentPnID that is null).</p> <p>My TreeView HierarchicalDataTemplate binding is:</p> <pre><code>&lt;TreeView x:Name="AssemblyTreeView" ItemsSource="{Binding BOMItems}"&gt; &lt;TreeView.ItemTemplate&gt; &lt;HierarchicalDataTemplate DataType="{x:Type local:MasterPartNumber}" ItemsSource="{Binding ParentBOMs.ChildPn}"&gt; &lt;TextBlock Text="{Binding pn}" /&gt; &lt;/HierarchicalDataTemplate&gt; &lt;/TreeView.ItemTemplate&gt; &lt;/TreeView&gt; </code></pre> <p>Which I believe to be correct. I can step through the debugger and see that the entire BOMItem navigation properties are populated (ParentBOM.ChildPn.pn) for each item that has child information.</p> <p>WHY am I unable to see these child properties populated in my TreeView?!</p> <pre><code>What I should get: Root Assembly --Sub Assembly ----Sub Assembly ------Child (n-levels deep) </code></pre> <p>And</p> <p>What I actually get:</p> <pre><code>Root Assembly </code></pre> <p>Do I need an additional converter? Do I need to define my ObservableCollection object wrapper's "getter" further?</p> <pre><code>Known possible sources of the problem: 1. Entity Framework is lazy loading, and just hasn't loaded the navigation properties I see in the debugger being populated. (No, set LazyLoading to false.) 2. My HierarchicalDataTemplate isn't probing for children just on the fact that it has children -- aka it only understands to switch the binding path when a new DataType is available, or something like that. (Not likely, because I've seen HierarchcialDataTemplates for self-referencing entities of a single entity type.) What I have right: 1. I can cascade down the binding route I told my TreeView to take in the debugger. Parent `pn` is populated as well as its `ParentBOMs.ChildPn.pn`. </code></pre> <p>Please help! Thank you !</p>
    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