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

[Solved] Binding DAta

4 Answers 76 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
al
Top achievements
Rank 1
al asked on 01 Apr 2009, 10:12 AM
Hi! can someone show me how to bind data in telerik treeview! what i am trying to do here is that, may data will come from WCF, and it is a list of records. I trying to do this

tmpQPSummary = e.Result;

 

trQPSummary.ItemsSource = tmpQPSummary.ToArray();

where e.result is a List<QuestionSummary> and QuestionSummary is a class containing the following field, QuestionTitle and QuestionDesciption

Even if i do it like this

tmpQPSummary = e.Result;

 

trQPSummary.ItemsSource = tmpQPSummary;

still doesnt work.


Thanks a lot...

4 Answers, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 01 Apr 2009, 11:17 AM
Hello al,

Are you specifying data templates for the data you receive from your WCF service? If not, probably this is the problem because the items you put in the treeview are not RadTreeViewItems and the tree does not know how to display them. When binding to a collection of custom business objects (what you get from your WCF service) you need to let the treeview know how you want these business objects to be displayed by specifying data templates.

Let me know if you have further questions.

Greetings,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
al
Top achievements
Rank 1
answered on 02 Apr 2009, 03:00 AM
Thank you for your immediate response!
Can you show me how to make a data template programatically. Becuase all the examples that i have seen, they are all map in the xaml file. i want to map it programtically. can you help me with it, and show me how it is done.

thanks...
0
Tihomir Petkov
Telerik team
answered on 02 Apr 2009, 08:10 AM
Hi al,

I would not recommend creating your data templates from the code-behind because it is not as elegant as the XAML alternative, takes more code, and is harder to maintain your code afterwards.

Anyways, I am attaching a sample project which demonstrates how to create and assign data templates programmatically.

Let me know if you have further questions.

Sincerely yours,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Tihomir Petkov
Telerik team
answered on 02 Apr 2009, 08:11 AM
Hello al,

Oops, forgot the attachment.

Best wishes,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
al
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
al
Top achievements
Rank 1
Share this question
or