简体   繁体   English

如何启用颜色选择器C#WPF Visual Studio 2015

[英]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: 在Visual Studio 2015中(尤其是在wpf应用程序中),在windows.resoures创建样式时,如下所示:

<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. 但是在重新安装Visual Studio之后,我无法双击并选择颜色。 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: 尝试添加画笔资源并在您的value字段中使用它,请尝试以下代码:

<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" 而不是双击,请右键单击并选择“编辑资源”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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