Only thing I can see wrong in the code you've posted is your Trigger
's Setter
sets both Background
and Foreground
to the same color {DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}
You could also maybe try setting the MultiTrigger
condition as Selector.IsSelectionActive
to be explicit:
I tried your posted code with these changes (Works fine for me in Windows-8):
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected"
Value="true" />
<Condition Property="Selector.IsSelectionActive"
Value="false" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
</MultiTrigger>
Output:
Note:
Your only setting Style
for the Top TreeViewItem
as TreeViewItemStyle1
. Hence the default Style
gets applied to the Child TreeViewItem
's which don't specify a Style
. If you want it to apply automatically to all TreeViewItem
's just remove the Style Key in declaration and it should be applied automatically based on the TargetType