|
1 | | -# How-to-set-the-header-template-in-DataGridTemplateColumn-in-.NET-MAUI-DataGrid |
2 | | -This demo shows how to set the header template in DataGridTemplateColumn in .NET MAUI DataGrid? |
| 1 | +# How to set the header template in DataGridTemplateColumn in .NET MAUI DataGrid? |
| 2 | +In this article, we will show you how to set the header template in DataGridTemplateColumn in [.Net Maui DataGrid](https://www.syncfusion.com/maui-controls/maui-datagrid). |
| 3 | + |
| 4 | +## xaml |
| 5 | +The code below demonstrates how to set the header template in DataGridTemplateColumn in DataGrid. |
| 6 | +``` |
| 7 | + <ContentPage.BindingContext> |
| 8 | + <local:EmployeeViewModel x:Name="viewModel"/> |
| 9 | + </ContentPage.BindingContext> |
| 10 | +
|
| 11 | + <syncfusion:SfDataGrid x:Name="sfGrid" |
| 12 | + GridLinesVisibility="Both" |
| 13 | + AutoGenerateColumnsMode="None" |
| 14 | + HeaderGridLinesVisibility="Both" |
| 15 | + ColumnWidthMode="Auto" |
| 16 | + ItemsSource="{Binding Employees}"> |
| 17 | +
|
| 18 | + <syncfusion:SfDataGrid.Columns> |
| 19 | + <syncfusion:DataGridTemplateColumn MappingName="EmployeeID" |
| 20 | + Format="#"> |
| 21 | + <syncfusion:DataGridTemplateColumn.HeaderTemplate> |
| 22 | + <DataTemplate> |
| 23 | + <Label Text="Employee ID" |
| 24 | + FontAttributes="Bold" |
| 25 | + TextColor="blue" |
| 26 | + VerticalOptions="Center" |
| 27 | + HorizontalOptions="Center" /> |
| 28 | + </DataTemplate> |
| 29 | + </syncfusion:DataGridTemplateColumn.HeaderTemplate> |
| 30 | + <syncfusion:DataGridTemplateColumn.CellTemplate> |
| 31 | + <DataTemplate> |
| 32 | + <Label Text="{Binding EmployeeID}" |
| 33 | + HorizontalOptions="End" |
| 34 | + VerticalOptions="Center" |
| 35 | + Padding="14" /> |
| 36 | + </DataTemplate> |
| 37 | + </syncfusion:DataGridTemplateColumn.CellTemplate> |
| 38 | + </syncfusion:DataGridTemplateColumn> |
| 39 | + <syncfusion:DataGridTextColumn MappingName="Name" |
| 40 | + HeaderText="Employee Name" /> |
| 41 | + <syncfusion:DataGridTextColumn MappingName="Title" |
| 42 | + HeaderText="Designation" /> |
| 43 | + <syncfusion:DataGridDateColumn MappingName="HireDate" |
| 44 | + HeaderText="Hire Date" /> |
| 45 | + </syncfusion:SfDataGrid.Columns> |
| 46 | +
|
| 47 | +</syncfusion:SfDataGrid> |
| 48 | +``` |
| 49 | + |
| 50 | +  |
| 51 | + |
| 52 | +[View sample in GitHub](https://github.com/SyncfusionExamples/How-to-set-the-header-template-in-DataGridTemplateColumn-in-.NET-MAUI-DataGrid) |
| 53 | + |
| 54 | +Take a moment to explore this [documentation](https://help.syncfusion.com/maui/datagrid/overview), where you can find more information about Syncfusion .NET MAUI DataGrid (SfDataGrid) with code examples. Please refer to this [link](https://www.syncfusion.com/maui-controls/maui-datagrid) to learn about the essential features of Syncfusion .NET MAUI DataGrid (SfDataGrid). |
| 55 | + |
| 56 | +##### Conclusion |
| 57 | + |
| 58 | +I hope you enjoyed learning about how to set the header template in DataGridTemplateColumn in .NET MAUI DataGrid (SfDataGrid). |
| 59 | + |
| 60 | +You can refer to our [.NET MAUI DataGrid’s feature tour](https://www.syncfusion.com/maui-controls/maui-datagrid) page to learn about its other groundbreaking feature representations. You can also explore our [.NET MAUI DataGrid Documentation](https://help.syncfusion.com/maui/datagrid/getting-started) to understand how to present and manipulate data. |
| 61 | +For current customers, you can check out our .NET MAUI components on the [License and Downloads](https://www.syncfusion.com/sales/teamlicense) page. If you are new to Syncfusion, you can try our 30-day [free trial](https://www.syncfusion.com/downloads/maui) to explore our .NET MAUI DataGrid and other .NET MAUI components. |
| 62 | + |
| 63 | +If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our [support forums](https://www.syncfusion.com/forums), [Direct-Trac](https://support.syncfusion.com/create) or [feedback portal](https://www.syncfusion.com/feedback/maui?control=sfdatagrid), or the feedback portal. We are always happy to assist you! |
0 commit comments