SelectedValue in RadTreeViewItem

2 posts, 0 answers
  1. vino
    vino avatar
    4 posts
    Member since:
    Oct 2010

    Posted 21 Dec 2010 Link to this post

        I am having RadTreeView name "ListGroupNames" and added 2 RadTreeViewItem like this.           




    <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.





    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.

  2. Petar Mladenov
    Petar Mladenov avatar
    2991 posts

    Posted 23 Dec 2010 Link to this post

    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.

    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top