Y
Y
youngpr2020-10-17 18:24:29
WPF
youngpr, 2020-10-17 18:24:29

How to apply multiple styles in DataGrid?

How to apply multiple styles in DataGrid? There is a style

<DataGrid.Columns>
                <DataGridTextColumn Header="ФИО" Binding="{Binding Name}" Width="180">
                    <DataGridColumn.HeaderStyle>
                        <Style TargetType="DataGridColumnHeader">
                            <Setter Property="FontWeight" Value="Bold"/>
                            <Setter Property="FontSize" Value="12"/>
                        </Style>
                    </DataGridColumn.HeaderStyle>
                    <DataGridTextColumn.ElementStyle>
                        <Style>
                            <Setter Property="TextBlock.TextWrapping" Value="Wrap" />
                            <Setter Property="TextBlock.TextAlignment" Value="Center"/>
                        </Style>
                    </DataGridTextColumn.ElementStyle>
</DataGridColumns>


Хочу применить такой стиль
 <DataGridTextColumn.ElementStyle>
        <Style TargetType="{x:Type TextBlock}">
            <Style.Triggers>
                <Trigger Property="Text" Value="John">
                    <Setter Property="Background" Value="LightGreen"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </DataGridTextColumn.ElementStyle>


I read that you can get around through BasedOn, but to apply BasedOn, you need to refer to the resource, I don’t know how to do this, you can write in the comments

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2020-10-18
@yarosroman

https://stackoverflow.com/questions/31340606/wpf-d...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question