本文介绍了Visual Studio扩展中的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发VS扩展,我想实现我的UI根据所选择的VS-color-scheme使用颜色(字体,背景等).做这个的最好方式是什么.我可以在WPF中绑定某些静态资源吗?
I'm developing a VS extension and I want to achieve that my UI will use colors (font, background etc.) depending on the selected VS-color-scheme. What is the best way to do this. Can I bind against some static ressources in my WPF?
推荐答案是的,绑定到静态VS资源是最好的方法. VS 2012+支持该功能,如下所示:
Yes, binding to static VS resources is the best approach. It is supported in VS 2012+ and looks like this:
<ResourceDictionary xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/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类颜色.
更多推荐
Visual Studio扩展中的颜色
发布评论