XAML:使用VS主题颜色制作TreeViewItem

Dav*_*eck 5 wpf treeview xaml colors visual-studio-2013

我正在创建一个带有工具窗口的Visual Studio扩展.我在那里使用TreeView.我希望此树视图使用当前的Visual Studio主题.感谢帖子你如何突出显示TreeViewItem?我能够设置文本和突出显示颜色.但还有更多问题:

  • 颜色只更新(重新)视觉工作室的开始,但不是直接更改主题时
  • 如何更改不专心的高光颜色?
  • 如何将可扩展图标颜色更改为当前主题颜色?
  • 在解决方案资源管理器窗口中,是否有机会完成突出显示?

这是我目前的XAML代码:

<UserControl x:Class="DavidSpeck.CSharpDocOutline.DocOutlineView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:shell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.12.0"
         Background="{DynamicResource VsBrush.Window}"
         Foreground="{DynamicResource VsBrush.WindowText}"
         mc:Ignorable="d"
         d:DesignHeight="300" d:DesignWidth="300"
         Name="MyToolWindow">
<UserControl.Resources>
    <Style x:Key="CETreeViewItem" TargetType="{x:Type TreeViewItem}">
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="{DynamicResource {x:Static shell:VsColors.ToolWindowTextKey}}" />
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource {x:Static shell:VsColors.HighlightKey}}" />
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="{DynamicResource {x:Static shell:VsColors.HighlightTextKey}}" />
        </Style.Resources>
    </Style>
</UserControl.Resources>
<Grid>
    <StackPanel Orientation="Vertical">
        <TreeView Name="outlineTreeView" 
                  Background="{DynamicResource VsBrush.Window}"
                  BorderThickness="0"
                  ItemContainerStyle="{StaticResource CETreeViewItem}">
        </TreeView>
    </StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)