Global style for GUI controls#
You will have two DataGrids in your GUI, which share the style. Like CSS in HTML technologies, you can define styles in App.axaml:
...
<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
<Style Selector="DataGrid">
<Setter Property="GridLinesVisibility" Value="All" />
<Setter Property="AutoGenerateColumns" Value="True" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Gray" />
</Style>
<Style Selector="StackPanel > :is(Control)">
<Setter Property="Margin" Value="5" />
</Style>
</Application.Styles>
...
Here we define global styles for DataGrids and each element in a StackPanel.