Xceed DataGrid for Silverlight Documentation
SetGroupContext Method
Example 


The element whose GroupContext is to be set.
The element's GroupContext.
Sets context-specific information for elements contained in a group. 
Syntax
'Declaration
 
Public Shared Sub SetGroupContext( _
   ByVal element As DependencyObject, _
   ByVal value As GroupContext _
) 
'Usage
 
Dim element As DependencyObject
Dim value As GroupContext
 
DataGridControl.SetGroupContext(element, value)
public static void SetGroupContext( 
   DependencyObject element,
   GroupContext value
)

Parameters

element
The element whose GroupContext is to be set.
value
The element's GroupContext.
Remarks

The GroupContext attached property will only be set on the first (i.e., root) element in the DataTemplate and can be accessed through a RelativeSource binding using the Self mode (see examples example below). Any child elements in the template can access the parent's GroupContext through an ElementName binding. For example:

<TextBlock Text="{Binding ElementName=parentPanel,
                                         Path=(sldg:DataGridControl.GroupContext).GroupValue}" />

The Items and ItemCount properties will always return null (Nothing in Visual Basic) and the IsItemCountEstimated property will always return false when the grid is bound to a virtualized data source.

Example
The code for the LanguageToVisibilityConverter class can be found in the Additional Resources section of the documentation.
<sldg:DataGridControl x:Name="sldgDataGridControl"
                      ItemsSource="{Binding Path=Orders}">
    <sldg:DataGridControl.Resources>
        <local:LanguageToVisibilityConverter x:Key="languageToVisibilityConverter" />
    </sldg:DataGridControl.Resources>
    <sldg:DataGridControl.GroupDescriptions>
        <sldg:DataGridGroupDescription PropertyName="ShipCountry">
            <sldg:DataGridGroupDescription.GroupConfiguration>
                <sldg:DataGridGroupConfiguration>
                    <sldg:DataGridGroupConfiguration.Headers>
                        <DataTemplate>
                            <TextBlock Text="{Binding RelativeSource={RelativeSource Self}, Path=(sldg:DataGridControl.GroupContext).GroupValue, StringFormat='{}{0} is a French-speaking country'}"
                                       Visibility="{Binding RelativeSource={RelativeSource Self}, Path=(sldg:DataGridControl.GroupContext), Converter={StaticResource languageToVisibilityConverter}}" />                   
                        </DataTemplate>
                    </sldg:DataGridGroupConfiguration.Headers>
                </sldg:DataGridGroupConfiguration>
            </sldg:DataGridGroupDescription.GroupConfiguration>
        </sldg:DataGridGroupDescription>
    </sldg:DataGridControl.GroupDescriptions>
</sldg:DataGridControl>
Requirements

Target Platforms: Windows 7, Windows Vista, Windows XP SP3, Windows Server 2008 family

See Also

Reference

DataGridControl Class
DataGridControl Members

Send Feedback