Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colors in Visual Studio Extension

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?

like image 552
Alexander Schmidt Avatar asked Sep 20 '13 09:09

Alexander Schmidt


People also ask

How do I enable colors in Visual Studio?

On the menu bar, choose Tools > Options. In the options list, choose Environment > General. In the Color theme list, choose either the default Dark theme, the Light theme, the Blue theme, or the Blue (Extra Contrast) theme.

What do the colors mean in Visual Studio?

Here's your quick reference to the colors and icons in the editor window's right-hand margin: Yellow: The line has been changed but not yet saved. Green: The line has been changed and saved. Orange: The line has been changed, saved, and the change undone. Little square dots in the middle of the margin: Break points.


1 Answers

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>

See EnvironmentColors Class for all avilable colors.

like image 130
Sergey Vlasov Avatar answered Oct 02 '22 02:10

Sergey Vlasov