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

SelectedValue in RadTreeViewItem

1 Answer 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
vino
Top achievements
Rank 1
vino asked on 21 Dec 2010, 11:50 AM
Hi,
    I am having RadTreeView name "ListGroupNames" and added 2 RadTreeViewItem like this.           

ObservableCollection

 

 

<RadTreeViewItem> list = new ObservableCollection<RadTreeViewItem>(){

 

 

 

                                        new RadTreeViewItem(){Header=ApplicationStrings.WorkflowDiagram},

 

 

 

                                        new RadTreeViewItem(){Header=ApplicationStrings.TemplateDiagram}};

 

ListGroupNames.ItemsSource = list;

And these 2 RadTreeViewItems i am adding some of the items like this.

 

void

 

 

ServiceRef_GetAllWorkFlowGroupNamesCompleted(object sender, DataReference.GetAllWorkFlowGroupNamesCompletedEventArgs e){
if (e.Result.Count != 0)
{
foreach (RadTreeViewItem items in ListGroupNames.Items)
{
if ((string)items.Header == ApplicationStrings.WorkflowDiagram)
{
items.ItemsSource = e.Result;
}}}
}

 



Here i am assigning ItemsSource to RadTreeViewItem .

My question is if i select any item means, both SelectedItem,SelectedValue both are having same values "EmpName" only.
But i need in SelectedItem "EmpName" and in SelectedValue "EmpId".

Since i am assigning ItemsSource to RadTreeViewItem, I am not having DisplayMemberPath,SelectedValuePath.

So what i need to do to get SelectedItem,SelectedValue like "EmpName","EmpId". in RadTreeViewItem.

Thanks,
Vinoth.J

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 23 Dec 2010, 02:20 PM
Hi vino,

First of all, I would like to notice that binding an ItemsSource Collection  filled with RadTreeView items is really bad practice. Your treeview actually wraps whatever you pass via the ItemsSource collection in RadTreeViewItems. So in your case you have items in items which is leads to lower performance and its harder to work with. The preferred way to bind the RadTreeView is to create a ViewModel class ( Business Object class and to define the properties you wish to use in it). Could you please examine the attached project and let us know if it satisfies you? Feel free ro ask if you need further assistance.

Greetings,
Petar Mladenov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
TreeView
Asked by
vino
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or