Improving the default style of the selected item for WPF tree views

Almost every tree item and list item in Windows has an attractive light blue effect with the selected item:

Pretty selected item effect

But when I create a simple tree view using WPF, the default effect is much less pleasant:

Ugly selected item effect

What do I need to do to change the element of the selected list item, which will consist of the effect in the upper screenshot? Is there any standard / system way to create this effect or do I need to create it myself using borders, fill in the effects (and, of course, select a color in MSPaint)

This is the xaml that I am currently using:

<TreeView Name="myTreeView" Margin="1">
    <TreeView.Resources>
        <HierarchicalDataTemplate DataType="{x:Type local:NodeType}" ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding Icon}" />
                <TextBlock Text="{Binding DisplayName}" Margin="5, 0" />
            </StackPanel>
        </HierarchicalDataTemplate>
    </TreeView.Resources>
</TreeView>
+3
source share
1 answer

+2

All Articles