0
我有以下的數據網格,並且我希望在網格設置爲只讀但不確定如何設置條件的情況下將cover = false的行顏色化。這個問題似乎是第一條件,其中蓋=假,如果我刪除此條件另一種是工作多觸發條件不適用於數據網格?
<DataGrid ItemsSource="{Binding AvailableRows}" AlternatingRowBackground="Lavender" Grid.Row="1"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertedBoolConverter}}" CanUserResizeColumns="True">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding TabName}" Header="Tab Name" CanUserSort="False" Width="1.5*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding GroupSummaryTabRowDescription.Description}" Header="Benefit" CanUserSort="False" Width="2*" IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridCheckBoxColumn Binding="{Binding Cover, Converter={StaticResource YNToBoolConverter}}" Header="Cover" CanUserSort="False" Width="1*"/>
<DataGridTextColumn Binding="{Binding RuleDescription, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Rule" CanUserSort="False" Width="3.5*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding AdditionalInfo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="Additional Info" CanUserSort="False" Width="4*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Cover}" Value="False"/>
<Condition Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, Path=IsReadOnly}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="Foreground" Value="Red" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
我不敢相信我錯過了!非常感謝您指出我的錯誤,解決了這個問題。 – soaloa