Extending RadTreeView & RadTreeViewItem

2 posts, 0 answers
  1. DTA
    DTA avatar
    6 posts
    Member since:
    Aug 2012

    Posted 04 Mar 2013 Link to this post


    Purpose: extending the RadTreeView & RadTreeViewItem
    In order to immplement the purpose above i had to inherit the both classes.
    When i binding the NewRadTreeView ItemSource to viewmodel
    i found the previous RadTreeViewItem instead NewRadTreeViewItem.

    In order to use my NewRadTreeViewItem i did the override below in NewRadTreeView & NewRadTreeViewItem:
    protected override DependencyObject GetContainerForItemOverride()
        var rti = base.GetContainerForItemOverride();
        if(rti is RadTreeViewItem)
            rti = new NewRadTreeView();

    I wonder if i'll have to expect for other things that might affect?
    What about the AddItem, Next, Previous etc...?

    Best regards
  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1237 posts

    Posted 07 Mar 2013 Link to this post


    In order to extend the RadTreeViewItem you have to override the IsItemItsOwnContainerOverride() method of the RadTreeView control. This method has to return false when its parameter equals the type of your customized RadTreeViewItem. By doing so the GetContainerForItemOverride() method will be invoked and you will be able to return a new instance of your extended RadTreeViewItem. For your convenience I implemented the approach in the attached solution. Please take a look at it and let me know if you need further assistance.

    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top