microsoft / VSExtensibility

A repo for upcoming changes to extensibility in Visual Studio, the new extensibility model, and language server protocol.
MIT License
367 stars 46 forks source link

Unable to get colour in ViewModel for Extensibility preview #398

Open DanGrowns opened 3 months ago

DanGrowns commented 3 months ago

Project type: Visual Studio Extensibility (preview)

Packages included:

I am trying to get a the foreground text colour in my ViewModel from the textblock dynamic resource style here: https://learn.microsoft.com/en-us/visualstudio/extensibility/visualstudio.extensibility/inside-the-sdk/advanced-remote-ui?view=vs-2022

I've created a brand-new project following the documentation above and attempted a few ways to transmit the dynamic resource to the VM.

I've tried using a CommandParameter on a button click to get the foreground colour of an element, however, when trying to transfer this as a parameter the command stops working.

I've added a reference to Microsoft.VisualStudio.Shell.15.0 to attempt to make use of: VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey);

However, this throws the error "this is a reference assembly".

Is there a way to get any VS theme information in the ViewModel for a out-of-process VS extension?

Thanks.

tinaschrepfer commented 2 months ago

Thanks for your feedback! Can you tell us a bit more about the scenario you're trying to enable where you need to get the color? What would you need the color for?

DanGrowns commented 2 months ago

Thanks - I am using SkiaSharp to draw images onto an Image control and display them in the add-in. I natively use the dark theme and would like to be able to identify the background colour of the addin so I can swap the image's colours.

e.g. When in dark mode, set SkiaSharp background text to VS background colour and foreground to white.