Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 1.46 KB

File metadata and controls

28 lines (23 loc) · 1.46 KB

How-to-make-TextAlignment-as-Center-for-all-Columns-in-MAUI-DataGrid-SfDataGrid-on-entire-applicat

The .NET MAUI DataGrid(SfDataGrid) allows to set the TextAlignment as Center for all columns in DataGrid on entire application through the implicit style as shown in the below code snippets.

XAML

Step 1 : Write the implicit style for DataGridCell and DataGridHeaderCell with TextAlignment property value as Center in App.Xaml.

<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:DataGridMAUI"
             xmlns:syncfusion="clr-namespace:Syncfusion.Maui.DataGrid;assembly=Syncfusion.Maui.DataGrid"
             x:Class="DataGridMAUI.App">
    <Application.Resources>
        <ResourceDictionary>
            <Style TargetType="syncfusion:DataGridCell">
                <Setter Property="TextAlignment" Value="Center"></Setter>
            </Style>
            <Style TargetType="syncfusion:DataGridHeaderCell">
                <Setter Property="TextAlignment" Value="Center"></Setter>
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

TextAlignment