Xceed DataGrid for Silverlight Documentation
GetStatContext Method
Example 


The element whose statistical context to retrieve.
Gets the context from which statistical functions retrieve the values needed to calculate their results and exposes the results through an indexer.
Syntax
'Declaration
 
Public Shared Function GetStatContext( _
   ByVal element As DependencyObject _
) As StatContext
'Usage
 
Dim element As DependencyObject
Dim value As StatContext
 
value = DataGridControl.GetStatContext(element)
public static StatContext GetStatContext( 
   DependencyObject element
)

Parameters

element
The element whose statistical context to retrieve.

Return Value

A StatContext representing the context from which statistical functions retrieve the values needed to calculate their results and exposes the results through an indexer.
Example
<Grid x:Name="LayoutRoot">
   <Grid.RowDefinitions>
      <RowDefinition Height="24" />
      <RowDefinition />
   </Grid.RowDefinitions>       

   <!-- Only the statistics that are calculated at the grid level can be accessed and displayed outside the grid. -->
   <TextBlock Text="{Binding ElementName=sldgDataGridControl, Path=(sldg:DataGridControl.StatContext)[TOTALPERSONCOUNT].Value, StringFormat='{}{0} people in total'}"
              Grid.Row="0" />
   <sldg:DataGridControl x:Name="sldgDataGridControl"
                         ItemsSource="{Binding Path=People}"
                         AutoCreateColumns="False"
                         Grid.Row="1">     
   
      <sldg:DataGridControl.GroupDescriptions>
         <sldg:DataGridGroupDescription PropertyName="Age">
            <sldg:DataGridGroupDescription.GroupConfiguration>
               <sldg:DataGridGroupConfiguration>
                  <sldg:DataGridGroupConfiguration.StatFunctions>
                     <!-- Any source property can be used when calculating the result of the count function. -->
                     <sldg:CountFunction ResultPropertyName="GROUP_PERSONCOUNT"
                                            SourcePropertyName="FirstName" />

                    </sldg:DataGridGroupConfiguration.StatFunctions>

                    <sldg:DataGridGroupConfiguration.FixedFooters>
                       <DataTemplate>
                          <sldg:StatRow x:Name="parentElement">
                             <sldg:StatCell FieldName="FirstName"
                                            ResultPropertyName="GROUP_PERSONCOUNT">
                                <sldg:StatCell.ContentTemplate>
                                   <DataTemplate>
                                      <StackPanel Orientation="Horizontal">
                                         <TextBlock Text="{Binding ElementName=parentElement,
                                                                                   Path=(sldg:DataGridControl.GroupContext).GroupValue,
                                                                                   StringFormat='{}The {0} age group contains '}" />
                                           <!-- The StatContext is set on the StatRow and can be accessed from the DataTemplate by
                                                   using and ElementName binding. Obviously, this implies that the parent StatRow has an
                                                   explicitly defined name.  

                                                   Unlike the GroupContext, which exposes its various properties directly, the StatContext exposes 
                                                   its dynamically created properties through an indexer. -->  
                                         <TextBlock Text="{Binding ElementName=parentElement, 
                                                                                   Path=(sldg:DataGridControl.StatContext)[GROUP_PERSONCOUNT].Value, 
                                                                                   StringFormat='{}{0} people'}"/>                                                       
                                      </StackPanel>
                                   </DataTemplate>
                                </sldg:StatCell.ContentTemplate>
                             </sldg:StatCell>
                          </sldg:StatRow>
                       </DataTemplate>
                    </sldg:DataGridGroupConfiguration.FixedFooters>
                 </sldg:DataGridGroupConfiguration>
              </sldg:DataGridGroupDescription.GroupConfiguration>
           </sldg:DataGridGroupDescription>
        </sldg:DataGridControl.GroupDescriptions>
   
        <sldg:DataGridControl.StatFunctions>
           <!-- Any source property can be used when calculating the result of the count function. -->
           <sldg:CountFunction ResultPropertyName="TOTALPERSONCOUNT"
                               SourcePropertyName="FirstName" />
           <sldg:MedianFunction ResultPropertyName="MEDIANAGE"
                                SourcePropertyName="Age" />
        </sldg:DataGridControl.StatFunctions>

        <sldg:DataGridControl.FixedFooters> 
           <sldg:StatRow>
              <sldg:StatCell FieldName="FirstName"
                                    ResultPropertyName="TOTALPERSONCOUNT"
                                    ResultConverterParameter="{}{0} people in total" />                         
           </sldg:StatRow>
           <TextBlock Text="{Binding RelativeSource={RelativeSource Self},
                                                     Path=(sldg:DataGridControl.StatContext)[MEDIANAGE].Value,
                                                     StringFormat='The median age is {0}'}" />
        </sldg:DataGridControl.FixedFooters>
   
        <sldg:DataGridControl.Columns>
           <sldg:Column FieldName="FirstName"
                        Title="First Name" />
           <sldg:Column FieldName="LastName"
                        Title="Last Name" />
           <sldg:Column FieldName="Age" />
           <sldg:Column FieldName="Birthday"/>
           <sldg:Column FieldName="HasChildren"
                        Title="Children"
                        VisiblePosition="99">                   
              <!-- This DataTemplate will automatically be applied as the corresponding StatCell's content template. -->
              <sldg:Column.CellContentTemplate>
                 <DataTemplate>
                    <CheckBox IsChecked="{Binding}" />
                 </DataTemplate>
              </sldg:Column.CellContentTemplate>
           </sldg:Column>
        </sldg:DataGridControl.Columns>
   </sldg:DataGridControl>
</Grid>
Requirements

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

See Also

Reference

DataGridControl Class
DataGridControl Members

Manipulating Data

Statistical Functions

Send Feedback