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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DNB

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

    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.Heade r = "Test1"//FOLLOWING LINE DOES NOT WORKtem.Foregro und = System.Drawing. Color.Red;item. Items.Add("*"); tree.Items.Add( item);ThanksDNB

  • Radek Cerny

    #2
    Re: WPF-How to add color to Tree View created dynamically in WPF

    does not work or does not compile?

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


    "DNB" <ii@ii.comwro te in message
    news:ed0TBydaIH A.1532@TK2MSFTN GP04.phx.gbl...
    >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.Heade r = "Test1"//FOLLOWING
    LINE DOES NOT WORKtem.Foregro und =
    System.Drawing. Color.Red;item. Items.Add("*"); tree.Items.Add( item);ThanksDNB
    >

    Comment

    Working...