Set TreeViewItem Name from code behind

2 posts, 0 answers
  1. Harsh
    Harsh avatar
    8 posts
    Member since:
    Jan 2009

    Posted 06 Feb 2009 Link to this post

    Hi,
    I am binding my tree with the collection.

     


    Now while adding an item to the tree view I want to set the header and the name of the Item node. 

    Currently I am able to set the header of the item added but when I try to set the name I get an error. 

    RadTreeViewItem
    objRadItem;

     

     

     

     

    objRadItem.Items.Add(

    new RadTreeViewItem()

     

    {

    Header = "Harsh",

     

    //Name = Convert.ToString(12)

     

     

     

    });

    How can I set the name of an item added?

     

  2. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 06 Feb 2009 Link to this post

    Hi Harsh,

    I wasn't able to reproduce your issue - setting the name from the code-behind works on my machine. Can you create a small project that is just isolating the issue and send it to me so that I can take a look.

    By the way, why do you need to set the Name property in the code-behind? As you can read on MSDN, "The name provides a reference so that code-behind, such as event handler code, can refer to a markup element after it is constructed during processing by a XAML processor".

    Sincerely yours,
    Tihomir Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top