How to conditional style a row of TreeViewList

4 posts, 1 answers
  1. Johnny
    Johnny avatar
    4 posts
    Member since:
    Aug 2009

    Posted 14 May 2013 Link to this post

    Hello,

    I have created a RadTreeViewList using mvvm pattern with a simple class named TreeItem:

    public class TreeItem
    {
        private string title;
        private ObservableCollection<TreeItem> items;
     
        public string Title
        {
            get { return title; }
            set { title = value; }
        }
     
        public ObservableCollection<TreeItem> Items
        {
            get { return items; }
            set { items = value; }
        }
     
        public TreeItem()
        {
     
        }
     
        public TreeItem(string ptitle)
        {
            this.Title = ptitle;
            this.Items = new ObservableCollection<TreeItem>();
        }
    }

    I manually create the object hierarchy and binded the control in code. I wanted to style the control as in the provided image, desired.png. However, what I was able to attained is shown in the image, result.png.

    I have studied the Style & Templates sections of both RadTreeViewList and RadGridView, but none of those guides "show" what part of the control they affect. If it is possible, please provide an example of how to style each row based on either indent position, or how to augment the data class to accomplish my goal.

    Thanks in advance.

    Johnny Moreno

  2. Answer
    Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 15 May 2013 Link to this post

    Hi Johnny,

    In order to achieve your goal, you can use RowStyleSelector. You can check this help article for a reference. For your convenience, I have prepared a sample project, illustrating the suggested approach. Please find it attached.


    All the best,
    Yoan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Johnny
    Johnny avatar
    4 posts
    Member since:
    Aug 2009

    Posted 15 May 2013 Link to this post

    Yoan, 

    Thanks for the rapid response. The example provided looks promising. I will try it and let you know.

    Thanks again,

    Johnny
  5. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 18 May 2013 Link to this post

    Hello Johnny,

    I am glad to see that you have Marked this as answer.

    Please if you face any further difficulties do not hesitate to contact us.

    Regards,
    Yoan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top