【发布时间】:2013-09-25 15:09:29
【问题描述】:
我正在开发一个 VS 扩展,我想实现我的 UI 将根据所选的 VS-color-scheme 使用颜色(字体、背景等)。做这个的最好方式是什么。我可以绑定 WPF 中的一些静态资源吗?
【问题讨论】:
标签: wpf visual-studio color-scheme vsix
我正在开发一个 VS 扩展,我想实现我的 UI 将根据所选的 VS-color-scheme 使用颜色(字体、背景等)。做这个的最好方式是什么。我可以绑定 WPF 中的一些静态资源吗?
【问题讨论】:
标签: wpf visual-studio color-scheme vsix
是的,绑定到静态 VS 资源是最好的方法。它在 VS 2012+ 中受支持,如下所示:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vs_shell="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.11.0">
<Style TargetType="Label">
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowTextBrushKey}}"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowTextBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowBackgroundBrushKey}}"/>
</Style>
</ResourceDictionary>
所有可用颜色请参见EnvironmentColors Class。
【讨论】: