Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding objects to a tree structure xaml
    primarykey
    data
    text
    <p>I am working on a WPF tree control. My class has objects which are a reference to another object. I want to be able to bind my objects in this class to be able to be bound to the tree in the xaml.</p> <p>This is what I have in my ViewModel and I want to bind each to a tree structure : </p> <pre><code>class PerformNewVehicleInquiryModel{ public List&lt;AddressDataType&gt; AddressDataVMField { get; set; } public List&lt;NetworkContolType&gt; NetworkControlVMField { get; set; } public List&lt;IdentificationType&gt; VehicleIdentificationVMField { get; set; } public List&lt;PerformNewVehicleInquiryRequestType&gt; PerformNewVehicleInquiryVMRequestField { get; set; } } //here is the method to add data to each node public List&lt;PerformNewVehicleInquiryModel&gt; getAllPerformNewVehicleInquiry() { // add to addressDataField List addressDataField.Add(new AddressDataType("AA", "A1")); addressDataField.Add(new AddressDataType("AA", "A1")); // add to networkControlField List //List&lt;NetworkContolType&gt; networkContolTypeList = new List&lt;NetworkContolType&gt;(); networkControlField.Add(new NetworkContolType(addressDataField, "22", "1305231128040001 1UNISC")); // create and add to identificationType List List&lt;IdentificationType&gt; identificationTypeList = new List&lt;IdentificationType&gt;(); identificationTypeList.Add(new IdentificationType("IdentificationType1")); identificationTypeList.Add(new IdentificationType("IdentificationType1")); // create and add to PerformNewVehicleInquiryRequestType List PerformNewVehicleInquiryRequestType performNewVehicleInquiryRequestType = new PerformNewVehicleInquiryRequestType(networkControlField, identificationTypeList); // add to list //List&lt;PerformNewVehicleInquiryRequestType&gt; performNewVehicleInquiryRequestTypeList = new List&lt;PerformNewVehicleInquiryRequestType&gt;(); performNewVehicleInquiryRequestField.Add(performNewVehicleInquiryRequestType); // create and add to PerformNewVehicleInquiryModel performNewVehicleInquiryModel.Add(new PerformNewVehicleInquiryModel(addressDataField, networkControlField, identificationTypeList, performNewVehicleInquiryRequestField)); return performNewVehicleInquiryModel; } // Bind tree to this observable list public ObservableCollection&lt;PerformNewVehicleInquiryViewModel&gt; PerformNewVehicleInquiries { get { return performNewVehicleInquiry; } set { if (performNewVehicleInquiry == value) return; performNewVehicleInquiry = value; NotifyPropertyChanged("PerformNewVehicleInquiries"); } } I am having hard time to bind this to a tree structure. it wont display the objects populated in the method above. </code></pre> <p>// Here is what my XAML Looks like now </p> <pre><code> &lt;TreeView.ItemTemplate&gt; &lt;HierarchicalDataTemplate ItemsSource="{Binding PerformNewVehicleInquiryVMRequestField}"&gt; &lt;TextBlock Foreground="Red" Text="{Binding NetworkContolType }" /&gt; &lt;!-- NetworkControlVMField template --&gt; &lt;HierarchicalDataTemplate.ItemTemplate&gt; &lt;HierarchicalDataTemplate ItemsSource="{Binding NetworkControlVMField}"&gt; &lt;TextBlock Text="{Binding AddressData}" /&gt; &lt;!-- AddressDataVMField template --&gt; &lt;HierarchicalDataTemplate.ItemTemplate&gt; &lt;HierarchicalDataTemplate ItemsSource="{Binding AddressDataVMField}"&gt; &lt;TextBlock Text="{Binding ApplicationID}" /&gt; &lt;!-- AddressDataVMField template --&gt; &lt;HierarchicalDataTemplate.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding MessageOriginatorID }" /&gt; &lt;/DataTemplate&gt; &lt;/HierarchicalDataTemplate.ItemTemplate&gt; &lt;/HierarchicalDataTemplate&gt; &lt;/HierarchicalDataTemplate.ItemTemplate&gt; &lt;/HierarchicalDataTemplate&gt; &lt;/HierarchicalDataTemplate.ItemTemplate&gt; &lt;/HierarchicalDataTemplate&gt; &lt;/TreeView.ItemTemplate&gt; &lt;/TreeView&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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