【问题标题】:Colors in Visual Studio ExtensionVisual Studio 扩展中的颜色
【发布时间】:2013-09-25 15:09:29
【问题描述】:

我正在开发一个 VS 扩展,我想实现我的 UI 将根据所选的 VS-color-scheme 使用颜色(字体、背景等)。做这个的最好方式是什么。我可以绑定 WPF 中的一些静态资源吗?

【问题讨论】:

    标签: wpf visual-studio color-scheme vsix


    【解决方案1】:

    是的,绑定到静态 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

    【讨论】:

    猜你喜欢
    • 2015-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-04
    • 1970-01-01
    • 1970-01-01
    • 2017-12-11
    • 1970-01-01
    相关资源
    最近更新 更多