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

Text not showing on Treeview

2 Answers 159 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 16 Apr 2010, 01:37 PM
I am adding nodes to a Treeview in the code behind like so:

private void CreateTreeviewNodes(Applications apps) 
        { 
            RadTreeListViewItem rootItem; 
            RadTreeListViewItem queriesItem; 
            RadTreeListViewItem queriesWorklistItem; 
            RadTreeListViewItem queriesNewQueryItem; 
 
            rootItem = new RadTreeListViewItem(); 
            rootItem.Header = "My Dashboard"
            rootItem.Foreground = new SolidColorBrush(Colors.Black); 
            rootItem.Selected += new EventHandler<RadRoutedEventArgs>(searchTreeView_RootItemSelected); 
 
            searchTreeView.Items.Add(rootItem); 
 
            for (int i = 0; i < apps.Count; i++) 
            { 
                rootItem = new RadTreeListViewItem(); 
                rootItem.Header = apps[i].Name; 
                rootItem.Foreground = new SolidColorBrush(Colors.Black); 
                rootItem.Selected += new EventHandler<RadRoutedEventArgs>(searchTreeView_RootItemSelected); 
 
                searchTreeView.Items.Add(rootItem); 
 
                queriesItem = new RadTreeListViewItem(); 
                queriesItem.Header = "Queries"
                rootItem.Foreground = new SolidColorBrush(Colors.Black); 
                queriesItem.Selected += new EventHandler<RadRoutedEventArgs>(searchTreeView_QueriesItemSelected); 
 
                rootItem.Items.Add(queriesItem); 
 
                queriesWorklistItem = new RadTreeListViewItem(); 
                queriesWorklistItem.Header = "Worklist"
                rootItem.Foreground = new SolidColorBrush(Colors.Black); 
                queriesItem.Selected += new EventHandler<RadRoutedEventArgs>(searchTreeView_QueriesWorklistItemSelected); 
 
                queriesItem.Items.Add(queriesWorklistItem); 
 
                queriesNewQueryItem = new RadTreeListViewItem(); 
                queriesNewQueryItem.Header = "New Query"
                rootItem.Foreground = new SolidColorBrush(Colors.Black); 
                queriesNewQueryItem.Selected += new EventHandler<RadRoutedEventArgs>(searchTreeView_QueriesNewQueryItemSelected); 
 
                queriesItem.Items.Add(queriesNewQueryItem); 
            } 
        } 

When I execute my code, however, the text on the RadTreeViewItems does not display until I select an item. If I then select another node its text displays but the text of the previously selected item disappears. Attached is a screenshot of the issue.

Can anyone tell me what is causing this or what I am doing wrong?

Thanks.













2 Answers, 1 is accepted

Sort by
0
Accepted
Valentin.Stoychev
Telerik team
answered on 16 Apr 2010, 01:40 PM
Hi Andrew,

I see you are adding RadTreeLISTViewItem to the RadTreeView? Try adding RadTreeViewItems.

Kind regards,
Valentin.Stoychev
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
Andrew
Top achievements
Rank 1
answered on 16 Apr 2010, 01:44 PM
And of course that fixes it. An obvious mistake and oversight on my part. Now I feel extremely silly. Thanks for the help, however. Who knows how long I'd have spent on this if someone had pointed on this simple error?
Tags
TreeView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or