Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF In-Code Preview Colour Feature VS2019

I would like to know if there is a setting for WPF in VS2019 to enable "colour preview" in code, such that when I type the hex colour code it displays the colour (without having to apply the colour to any UI element – just a pure visual preview)?

I have a project, where I use a multitude of colours, and it is getting difficult to keep track of which colour is which, so it would be nice to have a visual guide.

My general code for colours in the Resource Dictionary is:

<Color x:Key="BackgroundLight">#efefef</Color> 
<SolidColorBrush x:Key="BackgroundLightBrush" Color="{StaticResource BackgroundLight}" />

Is there such setting in VS2019? I believe I saw something like this in one youtube video, where the hex code was underlined by the corresponding colour, but I can neither figure out how to achieve that, nor can I find the video now.

like image 373
Tomáš Buchta Avatar asked Apr 29 '26 22:04

Tomáš Buchta


2 Answers

You can sometimes persuade the colour picker to appear in the properties window.

It is fiddly though and I must admit I can't recall trying with vs2019. EDIT: Having just tried this, I couldn't get it to work with just a color. A control like say the background on a grid with the hex in it works ok but the colorpicker doesn't respond at all when I select a color resource.

There's a vsix

https://marketplace.visualstudio.com/items?itemName=NikolaMSFT.InlineColorPicker

Like you're doing, I usually define colours in a resource dictionary so they have meaningful names.

Once I've done that, the actual colour matters a lot less.

like image 113
Andy Avatar answered May 02 '26 17:05

Andy


The newest version of VisualStudio implements this by default now. There is a coloured square next to the colour’s name. Nice.

like image 37
Tomáš Buchta Avatar answered May 02 '26 17:05

Tomáš Buchta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!