How to add multiple views in a DataGridCell in MAUI DataGrid?
The .NET MAUI DataGrid (SfDataGrid) allows add multiple views in a DataGridCell in SfDataGrid using the DataGridTemplateColumn. You can load any number of views in a DataGridCell by customizing the CellTemplate property of the DataGridTemplateColumn.
The below code illustrates how to add multiple views in a DataGridCell.
XAML
<syncfusion:SfDataGrid x:Name="dataGrid" AutoGenerateColumnsMode="None" ColumnWidthMode="Fill" ItemsSource="{Binding OrdersInfo}" RowHeight="180"> <syncfusion:SfDataGrid.Columns> <syncfusion:DataGridTemplateColumn HeaderText="Orders Information" MappingName="OrderID"> <syncfusion:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="100" /> <ColumnDefinition Width="100" /> <ColumnDefinition Width="100" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="40" /> <RowDefinition Height="40" /> <RowDefinition Height="40" /> <RowDefinition Height="40" /> </Grid.RowDefinitions> <Label Grid.Row="0" Grid.Column="0" FontAttributes="Bold" HorizontalTextAlignment="Center" Text="OrderID" TextColor="Black" VerticalTextAlignment="Center" /> <Label Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="Center" Text=":" TextColor="Black" VerticalTextAlignment="Center" /> <Label Grid.Row="0" Grid.Column="2" HorizontalTextAlignment="Center" Text="{Binding OrderID}" VerticalTextAlignment="Center" /> <Label Grid.Row="1" Grid.Column="0" FontAttributes="Bold" HorizontalTextAlignment="Center" Text="CustomerID" TextColor="Black" VerticalTextAlignment="Center" /> <Label Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="Center" Text=":" TextColor="Black" VerticalTextAlignment="Center" /> <Label Grid.Row="1" Grid.Column="2" HorizontalTextAlignment="Center" Text="{Binding CustomerID}" VerticalTextAlignment="Center" /> <Label Grid.Row="2" Grid.Column="0" FontAttributes="Bold" HorizontalTextAlignment="Center" Text="Freight" TextColor="Black" VerticalTextAlignment="Center" /> <Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="Center" Text=":" TextColor="Black" VerticalTextAlignment="Center" /> <Label Grid.Row="2" Grid.Column="2" HorizontalTextAlignment="Center" Text="{Binding Freight}" VerticalTextAlignment="Center" /> <Label Grid.Row="3" Grid.Column="0" FontAttributes="Bold" HorizontalTextAlignment="Center" Text="Country" TextColor="Black" VerticalTextAlignment="Center" /> <Label Grid.Row="3" Grid.Column="1" HorizontalTextAlignment="Center" Text=":" TextColor="Black" VerticalTextAlignment="Center" /> <Label Grid.Row="3" Grid.Column="2" HorizontalTextAlignment="Center" Text="{Binding Country}" VerticalTextAlignment="Center" /> </Grid> </DataTemplate> </syncfusion:DataGridTemplateColumn.CellTemplate> </syncfusion:DataGridTemplateColumn> </syncfusion:SfDataGrid.Columns> </syncfusion:SfDataGrid>
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 add multiple views in a DataGridCell in MAUI DataGrid (SfDataGrid).
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!