Visual Studio扩展中的颜色 [英] Colors in Visual Studio Extension

查看:155
本文介绍了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="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类颜色.

这篇关于Visual Studio扩展中的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆