Hello,
I have a treeview which I'm styling as such (and it works fine):
<Style x:Key="GenericTreeViewStyle" TargetType="{x:Type TreeView}">
<Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
</Style>
....
<TreeView Name="myTreeView" Style="{StaticResource GenericTreeViewStyle}" >
<TreeView.Resources>
<LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="Blue" Offset="0"/>
<GradientStop Color="DarkBlue" Offset="1"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="DarkGreen" Offset="0"/>
<GradientStop Color="Green" Offset="1"/>
</LinearGradientBrush>
<!-- Text in the TreeViewItem for when it's selected and focused -->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White" />
<!-- Text in the TreeViewItem for all other cases -->
<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Red" />
</TreeView.Resources>
</TreeView>
I'd like to make this a generic style that all instances of treeviews can pick up. So, I'd like to move everything from the TreeView.Resources chunk to GenericTreeViewStyle (or whatever other place necessary to achieve my goal). All my attempts have failed so far so I must be missing something. Appreciate your guidance please!