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

RadTreeListViewItem Datacontext is being set but DataTemplate for Rad Column can't bind to that datacontext being set in xaml

2 Answers 79 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 20 Jun 2010, 09:13 PM
Setting a RadTreeListViewItem's DataContext in xaml I can't then get access to that datacontext through <ContentPresenter Content="{Binding Content}" /> or this doesn't work too <ContentPresenter Content="{Binding Path=Content}" />

Example code below:

<

 

 

telerik:RadTreeListView x:Name="TreeListViewResults">  

<telerik:RadTreeListView.Columns>

 

<telerik:RadColumn Header="Name" Width="150" >

 

 

 

<telerik:RadColumn.CellTemplate>

 

 

 

<DataTemplate>

 

 

 

<ContentPresenter Content="{Binding Path=Content}"></ContentPresenter>

 

 

 

</DataTemplate>

 

 

 

</telerik:RadColumn.CellTemplate>

 

 

 

</telerik:RadColumn>

 

 

 

</telerik:RadTreeListView.Columns>

 

 

 

<telerik:RadTreeListViewItem x:Name="Testing" IsExpanded="true">

 

 

 

<telerik:RadTreeListViewItem.DataContext>

 

 

 

<l:CompareTreeListViewItem Content="Test" LeftElementName="Test1" RightElementName="Test2"></l:CompareTreeListViewItem>

 

 

 

</telerik:RadTreeListViewItem.DataContext>

 

 

 

</telerik:RadTreeListViewItem>

 

 

</telerik:RadTreeListView>

CompareTreeListViewItem is just a class with an object Content in it and 2 string properties named LeftElementName and RightElementName.     The result is that the Name columns shows up but the Content "Test" is not showing up under that column. I think this should work. Am I doing anything wrong?

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 23 Jun 2010, 11:31 PM
After downloading the silverlight Q2 2010 beta, this question seems to no longer matter. TreeListView has changed quite a bit. I now have a different question in the RadTreeListView.Items   I can't set items in the xaml. Is this on purpose. I don't want to use databinding to set my items, I want to do that through the xaml. There is no RadTreeListViewItem class anymore for the xaml.

Thanks
Matt
0
Vlad
Telerik team
answered on 24 Jun 2010, 06:18 AM
Hi Matt,

 Indeed RadTreeListView now is more like RadGridView. Can you post more info about what benefits you expect from declaring items in XAML instead setting ItemsSource?

Greetings,
Vlad
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
TreeListView
Asked by
Matt
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or