Search code examples
c#wpfcolorspicker

How to enable color picker c# wpf Visual Studio 2015


In Visual Studio 2015, specifically in a wpf application, when creating a style in windows.resoures like this:

<Window.Resources>
        <Style x:Key="DetailTextStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="Blue"/>
        </Style>
</Window.Resources>

The value of the foreground can be edited by double clicking it in properties.(image link has been attached. plz check). But after reinstalling Visual Studio I cannot double click and select color. I am able to do this on my laptop with same installation.

See image showing the value from properties.


Solution

  • Try to add a brush resource and use it in your value field, try this code:

    <Window.Resources>
        <SolidColorBrush x:Key="TestBrush" Color="Blue"/>
    
        <Style x:Key="DetailTextStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="Foreground" Value="{StaticResource TestBrush}"/>
        </Style>
    </Window.Resources>
    

    instead of double click do right click and pick "Edit Resource"