好吧,我已经看到这个代码来做到这一点:
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Black"/>
<Setter Property="Foreground" Value="Green">
</Setter>
</Trigger>
</Style.Triggers>
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource ucComponentesColorFilaMultiValueConverter}">
<Binding ElementName="dgdComponentes" Path="ItemsSource" />
<Binding ElementName="dgdComponentes" Path="SelectedItems" />
<Binding ElementName="CurrentItem" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</DataGrid.RowStyle>
Run Code Online (Sandbox Code Playgroud)
真的是代码是样式触发器,setter属性是针对其他情况的,但是我添加的代码可以影响结果.
我想更改选定的行背景,默认情况下是蓝色,我想根据某些条件使用其他颜色.例如,如果添加了一个寄存器,那么如果我选择该行它将为绿色,如果未选中该行,则它将为浅绿色.
我可以根据需要更改行的颜色,但是当我选择它时,总是蓝色.
谢谢.
TMa*_*Man 14
你可以试试这样的事......
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9541 次 |
| 最近记录: |