【问题标题】:WPF XAML Change Style color based on SystemColor.HighlightBrushKey 's opacity?WPF XAML 根据 SystemColor.HighlightBrushKey 的不透明度更改样式颜色?
【发布时间】:2015-04-21 09:37:33
【问题描述】:

我有 XamDataGrids,我想在应用程序范围内为其“活动”和“选定”行设置颜色。我创建了一个 ResourceDictionary 并没有问题。但是,我如何通过改变纯 XAML 中的不透明度(或者可能使用转换器)来将其中一种颜色作为系统颜色的基础?我想过在代码中制作一种颜色并改变它的不透明度,但我希望它是动态的,所以如果用户改变了系统的突出显示颜色,我的自定义颜色不会保持不变。

<Style TargetType="{x:Type igDP:DataRecordCellArea}">
    <Setter Property="BackgroundActive" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
    <Setter Property="BackgroundSelected" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
    <!--Want to set opacity of the BackgroundSelected color to 0.7 or so-->
</Style>

【问题讨论】:

    标签: c# wpf xaml colors


    【解决方案1】:

    我让它这样工作:

    <SolidColorBrush x:Key="HighlightSelectedColor" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" Opacity="0.7"/>
        <Style TargetType="{x:Type igDP:DataRecordCellArea}">
            <Setter Property="BackgroundActive" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
            <Setter Property="BackgroundSelected" Value="{StaticResource HighlightSelectedColor}" />
        </Style>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-14
      • 2018-08-30
      • 2016-06-20
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      相关资源
      最近更新 更多