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

Simple databound treeview doesnt work, why?

2 Answers 50 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Frank -
Top achievements
Rank 1
Frank - asked on 10 Jun 2011, 12:51 PM
I have a treeview in its simples form possible, can anyone explain why this little piece of code doesnt show my tree?

<UserControl x:Class="treeview.MainPage"
    xmlns:telerikNav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
    xmlns:telerikCon="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"             
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
  
    <Grid x:Name="LayoutRoot" Background="White">
        <telerikNav:RadTreeView Background="HotPink" ItemsSource="{Binding ParentList}"/>    
    </Grid>
</UserControl>


Imports System.ComponentModel
Imports System.Collections
Imports System.Collections.ObjectModel
  
Partial Public Class MainPage
    Inherits UserControl
  
    Public ParentList As New ObservableCollection(Of String)
  
    Public Sub New()
        InitializeComponent()
        PopulateList()
    End Sub
  
    Public Sub PopulateList()
        ParentList.Add("test")
        ParentList.Add("test1")
    End Sub
End Class

The background - hotpink displays but not test and test1 strings as expected.. Any ideas?

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 15 Jun 2011, 03:29 PM
Hello Frank -,

You haven't specified DataContext for the RadTreeView. I can suggest you to set the ItemsSource directly from code behind like so:
<telerikNav:RadTreeView Background="HotPink" x:name="tree">
Public Sub PopulateList() 
        ParentList.Add("test"
        ParentList.Add("test1"
        this.tree.ItemsSource = ParentList;
    End Sub
Let us know if you need further assistance on this.


Best wishes,
Petar Mladenov
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
Frank -
Top achievements
Rank 1
answered on 15 Jun 2011, 03:33 PM
Tags
TreeView
Asked by
Frank -
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Frank -
Top achievements
Rank 1
Share this question
or