I'm trying to set properties of a TreeViewItem
-> StackPanel
in c# like this question. It seems to make a lot of sense until I get to the part where I try to edit the Background
in my Border
. Borders
have Background
objects in them, but for the life of me I can't set a color or anything. It seems to be inconsistent because I can add Content
to a Label
by simply saying, Content = "Title"
.
Anyway, this is my code:
public static TreeViewItem childNode = new TreeViewItem() //Child Node
{
Header = new StackPanel
{
Orientation = Orientation.Horizontal,
Children =
{
new Border {
Width = 12,
Height = 14,
Background = ? //How do I set the background?
},
new Label {
Content = "Child1"
}
}
}
};
PS - I have the same problem when trying to add a BorderBrush
Thank you!