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.
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.
The newest version of VisualStudio implements this by default now. There is a coloured square next to the colour’s name. Nice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With