I am trying to build a TreeView in wpf. I need my parent and child to be in different colors, and I need that to be done for all the parents in that TreeView. If any node contains any child node, that colors also need to be changed.
I need that AMPHIBIANS and SPIDERS in same background color and all the child items should contains another background color. How to do this...?
So far i have tried
<Window.Resources>
    <Style TargetType="{x:Type TreeViewItem}">
        <Setter Property="Background" Value="#4E4E4E"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="FontSize" Value="15"/>
    </Style>
    <Style x:Key="styTvMenu" TargetType="{x:Type TreeView}">
        <Setter Property="Foreground" Value="Green"/>
    </Style>
</Window.Resources>
<Grid>
    <TreeView ItemsSource="{x:Static local:MainWindow.AnimalCategories}"  Style="{StaticResource styTvMenu}" Margin="0,0,321,0">
        <TreeView.ItemTemplate>
            <HierarchicalDataTemplate ItemsSource="{Binding Path=Animals}">
                <HierarchicalDataTemplate.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=Name}"/>
                    </DataTemplate>
                </HierarchicalDataTemplate.ItemTemplate>
                <TextBlock  Text="{Binding Path=Category}" />
            </HierarchicalDataTemplate>
        </TreeView.ItemTemplate>
    </TreeView>
</Grid>
