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

Binding 2 controls to 1 source

1 Answer 21 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Scott Michetti
Top achievements
Rank 1
Scott Michetti asked on 20 Mar 2014, 06:05 PM
Hello, I'm binding 2 TreeView controls to one source, and only 1 TreeView has data, the other is empty.
Here's my code.

radTreeview1.ItemsSource = MyClass.Children;
radTreeview2.ItemsSource = MyClass.Children;

radTreeview1 is blank. If I comment out radTreeview2, radTreeview1 displays with data, so it looks like the last item to bind will work.

Can I not use the same class to bind to 2 different controls?

Thanks,
Scott


1 Answer, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 25 Mar 2014, 09:49 AM
Hello Scott,

Yes you can use a single collection to populate two RadTreeViews. I attached a sample project that demonstrates a possible approach in which the code is much similar to yours:
          List<DataItem> children = MyClass.GetData();
       this.xTree1.ItemsSource = children;
       this.xTree2.ItemsSource = children;

Please let us know if this helps or if we have missed something.

Regards,
Boris Penev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

Tags
TreeView
Asked by
Scott Michetti
Top achievements
Rank 1
Answers by
Boris
Telerik team
Share this question
or