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

new RadTreeView() and databinding

3 Answers 74 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
SWAYAM KAR
Top achievements
Rank 1
SWAYAM KAR asked on 09 Apr 2010, 12:27 AM

Hello,

Databinding doesn't seem to work for me if I create a RadTreeview instance in the code and assign a HierarchicalDataTemplate as the item template. Here is what I am doing.

 

_treeInstallDates.ItemTemplate =

this.Resources["InstallTreeNodes"] as Telerik.Windows.Controls.HierarchicalDataTemplate;

 

 

ObservableCollection<POSInstallTreeModel> itemsToBind = new ObservableCollection<POSInstallTreeModel>();

 

installItems.ForEach(p => itemsToBind.Add(p));

_treeInstallDates.IsVirtualizing =

true;

 

_treeInstallDates.ItemsSource = itemsToBind;

_treeInstallDates.UpdateLayout();

And here is the XAML

 

 

 

<telerik:HierarchicalDataTemplate x:Key="InstallTreeLeafItems">

 

 

 

 

 

 

 

<StackPanel Orientation="Horizontal">

 

 

 

 

 

 

 

<Image Source="{Binding ImageSrc}" ToolTipService.ToolTip="{Binding TooltipText}">

 

 

 

</Image>

 

 

 

 

 

 

 

<TextBlock Text="{Binding StoreNum}"></TextBlock>

 

 

 

 

 

 

 

</StackPanel>

 

 

 

 

 

 

 

</telerik:HierarchicalDataTemplate>

 

 

 

 

 

 

 

<telerik:HierarchicalDataTemplate x:Key="InstallTreeNodes" ItemTemplate="{StaticResource InstallTreeLeafItems}" ItemsSource="{Binding StoreData}">

 

 

 

 

 

 

 

<TextBox Text="{Binding Path=POSInstallDate}"></TextBox>

 

 

 

 

 

 

 

</telerik:HierarchicalDataTemplate>

 

 

 

 

 

 

 

 

What am I doing wrong here?


3 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 12 Apr 2010, 03:25 PM
Hi SWAYAM KAR,

I am not sure what are the issues you are facing with your scenario. Can you please elaborate a bit? Also, from  the code snippet you provided I couldn't tell what might be causing problems.

Therefore, I prepared an example for you. Can you please take a look at it and let me know if this is what you had in mind? If not, can you please modify it to reproduce the issue you are facing?

All the best,
Tina Stancheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rakesh
Top achievements
Rank 1
answered on 13 Jul 2010, 04:41 PM
Hi Tina,

I have an issue with the databinding of treeviw in SL 4 VS 2010. C#.

I have an hierarchial data meaning all the root and children belong to the same class.

for e.g. lookup goes like this.

recruiterno          trackno
(null)                     100
100                        1001
100                        1002
1001                    10011

so, I am trying to bind the data in treeview and when I looked at the different types of binding that one can do in the treeview,  I looked at the examples like object datasource , hierarchial datsource
but no one example mentions how to bind heirarchial data of same class type to the treeviw. I have been researching all over for the past couple of days. If you can help me out, it would be great!!!

In asp .net: this is such a good example but I cant find like this one in silverlight
http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/databinding/defaultcs.aspx

Rakesh
0
Tina Stancheva
Telerik team
answered on 14 Jul 2010, 07:02 AM
Hello Rakesh,

Thank you for the clarification. Here is an example of how you can populate the RadTreeView with data from a self-referencing hierarchy.

Please take a look at it and let me know if it works for you or if you need more info.

All the best,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
SWAYAM KAR
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Rakesh
Top achievements
Rank 1
Share this question
or