Articles in this section
Category / Section

How to customize the Header of TreeViewAdv Columns?

1 min read

This article describes how to customize the header of TreeViewAdv columns with a common style.

TreeViewColumnHeader

Use TreeViewColumnHeader style to apply a common style for all the columns in TreeViewAdv control.

The following code example demonstrates the same by changing the foreground of column header.

XAML

<syncfusion:TreeViewAdv  MultiColumnEnable="True">  
         <syncfusion:TreeViewAdv.DataContext>
                <local:TreeView/>
            </syncfusion:TreeViewAdv.DataContext>     
            <syncfusion:TreeViewAdv.Resources>
                <Style TargetType="syncfusion:TreeViewColumnHeader"> 
                    <Setter Property="Foreground" Value="Red"/>
                </Style>
            </syncfusion:TreeViewAdv.Resources>
            <syncfusion:TreeViewItemAdv >
                <syncfusion:TreeViewItemAdv.Header>
                    <local:TreeView TreeHeader ="Item 1"  Description="Description about Item 1"/>
                </syncfusion:TreeViewItemAdv.Header>
            </syncfusion:TreeViewItemAdv>
            <syncfusion:TreeViewItemAdv>
                <syncfusion:TreeViewItemAdv.Header>
                    <local:TreeView TreeHeader ="Item 2" Description="Description about Item 2"/>
                </syncfusion:TreeViewItemAdv.Header>
            </syncfusion:TreeViewItemAdv>
            <syncfusion:TreeViewItemAdv>
                <syncfusion:TreeViewItemAdv.Header>
                    <local:TreeView TreeHeader ="Item 3" Description="Description about Item 3"/>
                </syncfusion:TreeViewItemAdv.Header>
            </syncfusion:TreeViewItemAdv>
            <syncfusion:TreeViewItemAdv>
                <syncfusion:TreeViewItemAdv.Header>
                    <local:TreeView TreeHeader ="Item 4" Description="Description about Item 4"/>
                </syncfusion:TreeViewItemAdv.Header>
            </syncfusion:TreeViewItemAdv>
            <syncfusion:TreeViewItemAdv>
                <syncfusion:TreeViewItemAdv.Header>
                    <local:TreeView TreeHeader ="Item 5" Description="Description about Item 5"/>
                </syncfusion:TreeViewItemAdv.Header>
            </syncfusion:TreeViewItemAdv>
           <syncfusion:TreeViewAdv.Columns   >
                <syncfusion:TreeViewColumnCollection  >
                    <syncfusion:TreeViewColumn  Width="200" Header="Name" 
       DisplayMemberBinding="{Binding Path=Header.TreeHeader, RelativeSource={RelativeSource AncestorType={x:Type syncfusion:TreeViewItemAdv}}}"/>
                    <syncfusion:TreeViewColumn Width="200" Header="Description"
       DisplayMemberBinding="{Binding Path=Header.Description, RelativeSource={RelativeSource AncestorType={x:Type syncfusion:TreeViewItemAdv}}}"/>
                 </syncfusion:TreeViewColumnCollection>
           </syncfusion:TreeViewAdv.Columns>
        </syncfusion:TreeViewAdv>                

 

C#

public class TreeView
    {
        private string header;
        public string TreeHeader
        {
            get { return header; }
            set { header = value; }
        }
 
        private string description;
        public string Description
        {
            get { return description; }
            set { description = value; }
        }
    }

 

The Output for the above code is shown below:

The out put in WPF TreeView



Conclusion

I hope you enjoyed learning about how to customize the Header of TreeViewAdv Columns.

You can refer to our  WPF TreeView feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF TreeView documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied