The color of all tree elements should be taken from Node x_color
Here, the color is determined by the triggers, and you need to set the Node tree
XAML
<TreeView x:Name="tw_tree_b"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="Foreground" Value="White" /> <Style.Triggers> <Trigger Property="IsSelected" Value="True" > <Setter Property="Foreground" Value="Silver"/> <Setter Property="FontWeight" Value="Normal"/> </Trigger> <Trigger Property="IsSelected" Value="False" > <Setter Property="FontWeight" Value="Normal"/> </Trigger> </Style.Triggers> </Style> </TreeView.ItemContainerStyle> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding collection_node}"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding name_}"> </TextBlock> </StackPanel> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> Node
public class Node { public string name_ { get; set; } public Color x_color { get; set; } // public ObservableCollection<Node> collection_node { get; set; }