Reputation: 6911
I have a need to highlight the MouseOver row of the datagrid, which seems to be easy with this style:
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
The problem is that I also have a style for some readonly cells defined as:
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Background" Value="LightGoldenrodYellow"/>
</Trigger>
</Style.Triggers>
</Style>
As a result, those readonly cells don't get MouseOver background. How do I solve this conflict? Your help is much appreciated.
Upvotes: 2
Views: 2341
Reputation: 4906
It is not a conflict. The MouseOver event is intended to work for normal row and cell which is not readonly.
You should add a MultiTrigger for this problem.
Sample:
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsReadOnly" Value="true" />
<Condition Property="IsMouseOver" Value="true" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="Green"/>
</MultiTrigger>
The code is valid for a style for DataGridCell. The completed code sample would be:
<Style TargetType="DataGridCell">
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsReadOnly" Value="true" />
<Condition Property="IsMouseOver" Value="true" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="Green"/>
</MultiTrigger>
</Style.Triggers>
</Style>
Upvotes: 2