简体   繁体   中英

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.

请参见显示属性值的图像。

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM