WPF-How to add color to Tree View created dynamically in WPF

D

DNB

I am trying to add color to tree View in WPF.

I am trying to use following line but it does not work:

item.Foreground = System.Drawing.Color.Red;



-------------------------------------------------------------------------------------------------TreeViewItem item = new TreeViewItem();item.Tag ="10"item.Header = "Test1"//FOLLOWING LINE DOES NOT WORKtem.Foreground = System.Drawing.Color.Red;item.Items.Add("*");tree.Items.Add(item);ThanksDNB
 
R

Radek Cerny

does not work or does not compile?

foreground needs to be a brush, so try .Foreground = new
SolidColorBrush(Colors.Red);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top