-
| <Style Selector="DataGridRow:selected"> </Style> |
Beta Was this translation helpful? Give feedback.
Answered by
sharpchen
Oct 8, 2025
Replies: 1 comment
-
|
Use this: <DataGrid.Styles>
<Style Selector="DataGridRow:selected /template/ DataGridCellsPresenter">
<Setter Property="Background" Value="Red"></Setter>
</Style>
</DataGrid.Styles>Because all styles have lower priority than local property assignment in xaml, while pseudo class is a event-like status that should be evaluated on runtime See discussions:
By the way to inspect what presenter you should target you can peek the source code of the control( [TemplatePart("PART_BottomGridLine", typeof (Rectangle))]
[TemplatePart("PART_CellsPresenter", typeof (DataGridCellsPresenter))]
[TemplatePart("PART_DetailsPresenter", typeof (DataGridDetailsPresenter))]
[TemplatePart("PART_Root", typeof (Panel))]
[TemplatePart("PART_RowHeader", typeof (DataGridRowHeader))]
[Avalonia.Controls.Metadata.PseudoClasses(new string[] {":selected", ":editing", ":invalid"})]
public class DataGridRow : TemplatedControl { ... } |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
s899000
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Use this:
Because all styles have lower priority than local property assignment in xaml, while pseudo class is a event-like status that should be evaluated on runtime
That's why we need a dedicated syntax
/template/to target the nested presenter typewe just need a way to let the styling system know it's something different so that it can manage the priority separately.
See discussions: