Homepage image
image RSS Feed

Sample Downloads: http://code.msdn.microsoft.com/CSSL4DataGridGroupHeaderSty-92ce9810 

Today’s sample illustrates how to define group header style of different levels and define group header style according to group header content.

imageYou can find more code samples that demonstrate the most typical programming scenarios by using Microsoft All-In-One Code Framework Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates. If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.

 

Introduction

This project created a sample application, which illustrates how to define group header style of different levels and define group header style according to group header content.
 

Prerequisites

Silverlight 4 Tools RTM for Visual Studio 2010
 http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b3deb194-ca86-4fb6-a716-b67c2604a139&displaylang=en
 
Silverlight 4 Toolkit for Visual Studio 2010
 http://silverlight.codeplex.com/

 

Implementation

1.    How to define group header style of different levels.
Group header style can be defined using DataGrid.RowGroupHeaderStyle Property and the styles are applied to different levels based on the order of style tag. The first one is applied to the most top level, the second for the second level and so on.

2.    How to vary group header style in one level.
In this sample, StackPanel is defined within the DataGrid.RowGroupHeaderStyle using Control.Template. The Background of StackPanel is binded to GroupHeaderName, and the background value is set based on GroupHeaderName using IValueConverter.

 

References

DataGrid.RowGroupHeaderStyles Property
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.rowgroupheaderstyles.aspx
Control.Template Property
http://msdn.microsoft.com/en-us/library/system.windows.controls.control.template.aspx
Style.TargetType Property
http://msdn.microsoft.com/en-us/library/system.windows.style.targettype.aspx