Skip to content

Commit

Permalink
Do not hardcode Margin and VerticalAlignment on data grid text column
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkatz6 committed Jan 18, 2022
1 parent c04f906 commit 48bad22
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,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>
Expand Down Expand Up @@ -162,8 +160,7 @@ protected override IControl GenerateElement(DataGridCell cell, object dataItem)
{
TextBlock textBlockElement = new TextBlock
{
[!Layoutable.MarginProperty] = new DynamicResourceExtension(DATAGRID_TextColumnCellTextBlockMarginKey),
VerticalAlignment = VerticalAlignment.Center
Name = "CellTextBlock"
};

SyncProperties(textBlockElement);
Expand Down
4 changes: 4 additions & 0 deletions src/Avalonia.Controls.DataGrid/Themes/Default.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" />
Expand Down
5 changes: 5 additions & 0 deletions src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 48bad22

Please sign in to comment.