Before continuing this article, I highly recommend reading these previous parts:
Data TemplateThe DataGrid control not only displays data in a row and column format but it can also be used to display data in a templated format. The template is used to display a row data grouped into a template. You can define a data template as either XAML or as a resource. Imagine you need to display 50 fields in a DataGrid but a row can only display up to 10 columns. So how do you display more columns? You can use a DataTempate to do so. If you look at Figure 13, you will see the DataGrid row has 5 columns but 3 additional columns are displayed as a part of the data template. Figure 13RowDetailsTemplateThe RowDetailsTemplate property represents the DataTemplate that is used to display a row details. The LoadingRowDetails and UnloadingRowDetails events are used to load and unload the data template or making changes. A DataTemplate value is set as the RowDetailsTemplate of the DataGrid. The DataTemplate defines the vsual representation of all XAML elements of a row. Listing 34 shows how to set the RowDetailsTemplate property of the DataGrid.
SummaryIn this article of the Mastering WPF DataGrid series, we saw how to use a DataTemplate to format a DataGrid row data.In the next and final article of this series, I will discuss how to implement CRUD functionality in a DataGrid.
<<Previous Article Next Article>>