WPF XAML 根据 SystemColor.HighlightBrushKey 的不透明度更改样式颜色?
WPF XAML Change Style color based on SystemColor.HighlightBrushKey 's opacity?
我有 XamDataGrids,我想为其 "Active" 和 "Selected" 行应用程序范围设置颜色。我创建了一个 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>
我是这样工作的:
<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>
我有 XamDataGrids,我想为其 "Active" 和 "Selected" 行应用程序范围设置颜色。我创建了一个 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>
我是这样工作的:
<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>