Browse Source

Do not hardcode Margin and VerticalAlignment on data grid text column

pull/7292/head
Max Katz 5 years ago
parent
commit
f7e8b7658f
  1. 5
      src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs
  2. 4
      src/Avalonia.Controls.DataGrid/Themes/Default.xaml
  3. 5
      src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml

5
src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs

@ -19,8 +19,6 @@ namespace Avalonia.Controls
/// </summary>
public class DataGridTextColumn : DataGridBoundColumn
{
private const string DATAGRID_TextColumnCellTextBlockMarginKey = "DataGridTextColumnCellTextBlockMargin";
/// <summary>
/// Initializes a new instance of the <see cref="T:Avalonia.Controls.DataGridTextColumn" /> class.
/// </summary>
@ -178,8 +176,7 @@ namespace Avalonia.Controls
{
TextBlock textBlockElement = new TextBlock
{
[!Layoutable.MarginProperty] = new DynamicResourceExtension(DATAGRID_TextColumnCellTextBlockMarginKey),
VerticalAlignment = VerticalAlignment.Center
Name = "CellTextBlock"
};
SyncProperties(textBlockElement);

4
src/Avalonia.Controls.DataGrid/Themes/Default.xaml

@ -29,6 +29,10 @@
</ControlTemplate>
</Setter>
</Style>
<Style Selector="DataGridCell > TextBlock#CellTextBlock">
<Setter Property="Margin" Value="{DynamicResource DataGridTextColumnCellTextBlockMargin}" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style Selector="DataGridColumnHeader">
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />

5
src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml

@ -145,6 +145,11 @@
</Setter>
</Style>
<Style Selector="DataGridCell > TextBlock#CellTextBlock">
<Setter Property="Margin" Value="{DynamicResource DataGridTextColumnCellTextBlockMargin}" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style Selector="DataGridCell /template/ Rectangle#CurrencyVisual">
<Setter Property="IsVisible" Value="False" />
</Style>

Loading…
Cancel
Save