I have two Many-To-Many with Payload entities as shown below:
So, to make an Assembly stored in MasterPartNumber with a part number: MasterPartNumber.pn
, I use the navigation property ParentBOMs
, which is given by the relationship:
MasterPartNumber.pnID = MasterPartsList.parentPnID
.
This gives me all the child pnIDs under that parent assembly.
To get the child part numbers for that assembly, I use the ChildPn
navigation property, defined by MasterPartsList.pnID = MasterPartNumber.pnID
.
Please note that top level assembly items are NOT listed in MasterPartsList (they would have a parentPnID that is null).
My TreeView HierarchicalDataTemplate binding is:
<TreeView x:Name="AssemblyTreeView"
ItemsSource="{Binding BOMItems}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate DataType="{x:Type local:MasterPartNumber}"
ItemsSource="{Binding ParentBOMs.ChildPn}">
<TextBlock Text="{Binding pn}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
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.
WHY am I unable to see these child properties populated in my TreeView?!
What I should get:
Root Assembly
--Sub Assembly
----Sub Assembly
------Child (n-levels deep)
And
What I actually get:
Root Assembly
Do I need an additional converter? Do I need to define my ObservableCollection object wrapper's "getter" further?
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`.
Please help! Thank you !
ObservableCollection
), and what theHierarchicalDataTemplate
is actually binding to. – Frazzle