2

So I thought I'd run this out there, and see if I was missing something idiotic.

I developed a small my-use-only VSIX extension, and in one of my toolwindows, I'm using the code to set the foreground/background color:

    Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}"
    Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolboxBackgroundKey}}"

The vsfx: namespace is referenced as:

    xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"

I see the 10.0 referenced there, and for me, that's expected as I originally did this up in VS2010. Now that my work has made me upgrade to VS2012, the XAML designer is giving me the following error on those two SynamicResources. The error reads 'The resource {x:Static vsfx:VsBrushes.ToolWindowTextKey} could not be resolved.' and like for the second one.

Now, note that the project still builds and runs, and can be loaded into VS2012. However, the colors are all off (standard, don't match the theme that VS is set to.)

Any thoughts on what to check or look for?

Cheers - Mike.

Coyttl
  • 537
  • 1
  • 4
  • 19
  • Have you solved the problem? – Alexey Raga May 13 '13 at 10:23
  • Technically, no. I went ahead and set all the resources in code to get around this (annoying) issue. I'm sure it's something I did, but the messages/error isn't giving me enough information to do a reliable google search on. :( – Coyttl May 16 '13 at 14:14
  • I did. {DynamicResource VsBrush.ToolWindowText} works. You will not have any intellisense on VsBrush, but literally you just use VsBrush instead of VsBrushes and get rid of the "Key" suffix. And because it is the resource identifier itself, you don't need to wrap it with {x:Static. – Alexey Raga May 18 '13 at 02:44

2 Answers2

1

I ran into the same question as you guys do, and found out the follow facts:

[VsBrushes/VsBrush] v.s. [EnviromentColors]:

  1. VsBrushes and VsBrush are basically the same thing, supported in VS2010/2012/2013;
  2. EnviornmentColors is only in VS2012/2013, not supported in VS2010;
  3. EnvironmentColors is still envolving, more colors will be added in for new themes; VsBrushes/VsBrush are relatively static.

[VsBrushes] v.s. [VsBrush]:

  1. Good thing about “VsBrushes” is that it checks whether a specific color name exists during building.
  2. Bad thing about “VsBrushes” is that is has to specify the VS namespace and assembly version in the XAML file head, which is inconvenient. (e.g. xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0")

Thanks.

RainCast
  • 4,134
  • 7
  • 33
  • 47
-1

Use EnvironmentColors class as it's stated here: http://msdn.microsoft.com/en-us/library/vstudio/jj991932.aspx

desegel
  • 421
  • 3
  • 10