Reputation:
I'm using material design in XAML, I have a DataGrid, and when a row is selected and the mouse leaves the row then the row's background changes to white, if the mouse returns it changes back to the original color. I think I have found the part of the code that sets it but I don't seem to be able to overwrite it... This is in the 'MaterialDesignDataGridCell' style and to me it seems this sets it.
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True"/>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource MaterialDesignSelection}" />
</MultiDataTrigger>
I tried copying this trigger and setting a different value, setting up a trigger just when the mouseover is false to set the background, and tried setting these with no luck :
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Black"/>
</Style.Resources>
Upvotes: 0
Views: 890
Reputation: 414
Not really sure what you are trying to achieve but if you want to override the cell style for your datagrid cells you can do like this
<DataGrid>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True"/>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="Red" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
</DataGrid>
Upvotes: 1