Skip to content

Overriding DataGridRow Style #1492

@killnine

Description

@killnine

Hi guys,

I've applied the code below to a DataGrid. My goal is to get the foreground text of a row to show up red if the data trigger is met.

<DataGrid.RowStyle>
    <Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource MetroDataGridRow}">
    <Setter Property="behaviors:DataGridRowDoubleClickBehavior.DoubleClickCommand" Value="{Binding ElementName=EventGrid, Path=DataContext.ModifyEventForm.OpenFormCommand}"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsTransferred}" Value="True">
                <Setter Property="Foreground" Value="Gray"/>
                <Setter Property="FontStyle" Value="Italic"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=OpCode}" Value="999">
                <Setter Property="Foreground" Value="DarkRed"/>
                <Setter Property="FontWeight" Value="Bold"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</DataGrid.RowStyle>

However, only the FontStyle and FontWeights are affected. I am assuming this is because the Foreground is set in MA.M's styles via Triggers on things like 'IsSelected'.

Is there a working solution for overriding things like this? I'm no master of style hierarchy in WPF :)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions