以下に示すように、ペイロードを持つ 2 つの多対多エンティティがあります。
したがって、部品番号: で MasterPartNumber に格納されたAssemblyを作成するには、関係: によって与えられる
MasterPartNumber.pn
ナビゲーション プロパティ を使用します。これにより、その親アセンブリの下にあるすべての子 pnID が得られます。ParentBOMs
MasterPartNumber.pnID = MasterPartsList.parentPnID
そのアセンブリの子部品番号を取得するにはChildPn
、 で定義されたナビゲーション プロパティを使用しMasterPartsList.pnID = MasterPartNumber.pnID
ます。
最上位のアセンブリ アイテムは MasterPartsList にリストされないことに注意してください (これらのアイテムの parentPnID は null になります)。
私の TreeView HierarchicalDataTemplate バインディングは次のとおりです。
<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>
私は正しいと信じています。デバッガーをステップ実行すると、子情報を持つ各アイテムの BOMItem ナビゲーション プロパティ全体 (ParentBOM.ChildPn.pn) が設定されていることがわかります。
これらの子プロパティが TreeView に入力されているのを確認できないのはなぜですか?!
What I should get:
Root Assembly
--Sub Assembly
----Sub Assembly
------Child (n-levels deep)
と
私が実際に得るもの:
Root Assembly
追加のコンバーターが必要ですか? ObservableCollection オブジェクト ラッパーの「ゲッター」をさらに定義する必要がありますか?
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`.
助けてください!ありがとうございました !