This is a migrated thread and some comments may be shown as answers.

Two Collection Binding

4 Answers 69 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Heather
Top achievements
Rank 1
Heather asked on 23 Sep 2009, 12:55 PM
I have a GridView with a ItemsSource of WorkOrder.WorkItems bound in XAML.  I then use RowDetails to show the details of the WorkOrderItem.  In my rowdetails I am showing a few properties of the item and also want to use a TreeView to display Parts and Labor related to the WorkOrderItem.  What I'd like to do is create the TreeView with 2 static nodes.  One of the nodes ItemSource would be WorkItem Parts collection and the other wouold have an ItemSource of WorItem Labor.  I would them implement a DataTemplateSelector to determine which template to use to display the children of each node.  Is this doable?

Example:
WorkOrder
    WorkItems as ObservableCollection(of WorkItem)
WorkItem
     WorkItemType as String
    DueDate as DateTime
    Parts as ObservableCollection(of WorkItemPart)
    Labor as ObservableCollection(of WorkItemLabor)
    

<DataTemplate x:Key="DetailsTemplate">
<StackPanel>
<TextBox Text={Binding WorkItemType}/>
<telerikNavigation:RadTreeView>
  <telerikNavigation:RadTreeViewItem ItemsSource={Binding Parts} Header="Parts"/>
  <telerikNavigation:RadTreeViewItem ItemsSource={Binding Labor} Header="Labor"/>
</telerikNavigation:RadTreeView>
</StackPanel>
</DataTemplate>

<telerikGridView:RadGridView ItemSource={Binding WorkOrder.WorkItems} RowDetailsTemplate="{StaticResource DetailsTemplate}" />

4 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 24 Sep 2009, 12:03 PM
Hello Heather,

If you know the two static nodes you can create them declaratively and then to bind the ItemsSource property of the TreeViewItem to the desired collection.

The other option ofcourse is to simply use two treeviews.

Best wishes,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Heather
Top achievements
Rank 1
answered on 24 Sep 2009, 12:27 PM
Should I be able to do it in XAML (similar to what I posted)?  I tried a variety of ways and could not get it to work.
0
Valentin.Stoychev
Telerik team
answered on 26 Sep 2009, 07:08 AM
Hi Heather,

Yes - it should work. If the items are not populated this means that for some reason the data is not there. Can you check it the data you atr trying to bind to is actually available.

Best wishes,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Heather
Top achievements
Rank 1
answered on 28 Sep 2009, 12:54 PM
Sorry, problem on the backend with the data.  Its working fine now.  Thank you.

Heather
Tags
TreeView
Asked by
Heather
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Heather
Top achievements
Rank 1
Share this question
or