Skip to content

SyncfusionExamples/How-to-apply-padding-for-Column-Elements-in-MAUI-DataGrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to apply padding for Column Elements in MAUI DataGrid?

By default the .NET MAUI DataGrid has padding values applied to each cell.

XAML

We can update the padding of each cell using CellPadding and HeaderPadding. CellPadding targets the DataGridCell, while HeaderPadding targets the DataGridHeaderCell.

<syncfusion:SfDataGrid x:Name="dataGrid"
                    x:DataType="local:EmployeeViewModel"
                    RowHeight="30"
                    ColumnWidthMode="Auto"
                    ItemsSource="{Binding Employees}">
    <syncfusion:SfDataGrid.Columns>
        <syncfusion:DataGridNumericColumn MappingName="EmployeeID" HeaderText="Employee ID" Format="D" CellPadding="0" HeaderPadding="0"/>
        <syncfusion:DataGridTextColumn MappingName="Name" CellPadding="16, 0 ,16, 0" HeaderPadding="16 ,0, 16, 0" />
        <syncfusion:DataGridTextColumn MappingName="Title" CellPadding="16, 0, 16, 0" HeaderPadding="16, 0, 16, 0"/>
    </syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>

C#

Similar code as XAML

DataGridNumericColumn EmployeeIDColumn = new DataGridNumericColumn() { MappingName = "EmployeeID" , HeaderText = "Employee ID" , Format= "D" , CellPadding  = new Thickness(16,0,16,0), HeaderPadding = new Thickness(16,0,16,0) };

DataGridTextColumn NameColumn = new DataGridTextColumn() { MappingName = "Name", HeaderText = "Name",  CellPadding = new Thickness(16, 0, 16, 0), HeaderPadding = new Thickness(16, 0, 16, 0) };

DataGridTextColumn Title = new DataGridTextColumn() { MappingName = "Title", HeaderText = "Title", CellPadding = new Thickness(16, 0, 16, 0), HeaderPadding = new Thickness(16, 0, 16, 0) };

dataGrid.Columns.Add(EmployeeIDColumn);
dataGrid.Columns.Add(NameColumn);
dataGrid.Columns.Add(Title);

DataGrid padding

View sample in GitHub

Take a moment to pursue this documentation, where you can find more about Syncfusion .NET MAUI DataGrid (SfDataGrid) with code examples. Please refer to this link to learn about the essential features of Syncfusion .NET MAUI DataGrid(SfDataGrid).

Conclusion

I hope you enjoyed learning about how to apply padding for Column Elements in MAUI DataGrid?

You can refer to our .NET MAUI DataGrid's feature tour page to know about its other groundbreaking feature representations. You can also explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data. For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our .NET MAUI DataGrid and other .NET MAUI components. If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac or feedback portal. We are always happy to assist you!

About

How to apply padding for Column Elements in MAUI DataGrid?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages