using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Avalonia.Data;
using Avalonia.Layout;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InABox.Avalonia.Components;

public class AvaloniaDataGridTextColumn<TEntity> : AvaloniaDataGridColumn<TEntity, string>
{
    public override DataGridColumn CreateColumn()
    {
        var column = CreateColumn<DataGridTemplateColumn>();
        column.CellTemplate = new FuncDataTemplate<object?>((value, scope) =>
        {
            var label = new TextBlock
            {
                Margin = new(2, 0, 0, 0),
                TextAlignment = Alignment,
                VerticalAlignment = VerticalAlignment.Center
            };
            label.Bind(TextBlock.TextProperty, new Binding(ColumnName));
            return label;
        });
        return column;
    }
}
