Hi.
I have this treeview, programatically created (adding the nodes)
When each child nodes OPC-Tag changes, (it comes with 1 or 0).
The OPC-Tag comes in just nicely.
And each time the tags updates i call this function
private void UpdateStatuses(string strTag, string sStatus) { foreach (Thing tvi in tv.Items) { bool bRed = false; foreach (Thing tva in tvi.Children) { if (tva.Tag == strTag) { if (sStatus == "0") { tva.StatusBrush = new SolidColorBrush(Colors.Red); tva.Name = strTag; bRed = true; } else { tva.StatusBrush = new SolidColorBrush(Colors.Green); } } } tb3.Text = "\nRed: " + bRed; if (bRed) { tvi.StatusBrush = new SolidColorBrush(Colors.Red); } else { tvi.StatusBrush = new SolidColorBrush(Colors.Green); } } tv.ExpandAll(); }
But the Illipse does not change the color, and where i try to change the
tva.Name = strTag;
The child node still have the old name.
What i am trying to accomplis is
* Reflect the color of each node according to the tag value
* Update the parent node so, if any listed node is not green, the parent node should be red, else be green.
Each item is this class
public class Thing { public SolidColorBrush StatusBrush { get; set; } public string Name { get; set; } public string Tag { get; set; } public ObservableCollection<Thing> Children { get; set; } }