We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Treeview programatically change node colour

Thread ID:

Created:

Updated:

Platform:

Replies:

129755 Apr 1,2017 11:56 PM UTC Apr 3,2017 12:39 PM UTC WPF 1
loading
Tags: TreeViewAdv
Richard
Asked On April 1, 2017 11:56 PM UTC

I have a treeview which load data via a binding to a nodes collection.

Currently, all the nodes are the same colour. How can I change individual nodes depending on the node item bound to that node? Preferably leaving the styling in the XAML

Durga Rajan [Syncfusion]
Replied On April 3, 2017 12:39 PM UTC

Hi Richard, 
 
Thank you for contacting Syncfusion Support. 
 
We have analyzed your query and prepared sample to meet your requirement. We can achieve your requirement by customizing the ItemTemplate of TreeView. Kindly make use of below codes, 
 
Code Snippet: [XAML] 
  
                    <syncfusion:TreeViewAdv.ItemTemplate> 
 
                <HierarchicalDataTemplate ItemsSource="{Binding SubItems}"> 
 
                 <TextBlock Text="{Binding Header}" Foreground="{Binding ForeColor}" /> 
 
                </HierarchicalDataTemplate> 
                 
 
            </syncfusion:TreeViewAdv.ItemTemplate> 
  
  
Code Snippet: [C#] 
 
Model Root1 = new Model() { Header = "Root1", ForeColor = new SolidColorBrush(Colors.Red) }; 
 
Screenshot : 
 
 
 
Please download the sample from the following location. 
 
Sample: TreeViewTest 
 
Regards, 
Durga S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;