Xceed DataGrid for WPF v7.3 Documentation
Xceed.Wpf.DataGrid Assembly / Xceed.Wpf.DataGrid Namespace / DataGridDetailDescription Class / StatFunctions Property
Example


In This Topic
    StatFunctions Property (DataGridDetailDescription)
    In This Topic
    Gets a collection of the statistical functions whose results can be used by various elements throughout the detail.
    Syntax
    'Declaration
     
    Public ReadOnly Property StatFunctions As StatFunctionCollection
    'Usage
     
    Dim instance As DataGridDetailDescription
    Dim value As StatFunctionCollection
     
    value = instance.StatFunctions
    public StatFunctionCollection StatFunctions {get;}

    Property Value

    A StatFunctionCollection that contains a collection of statistical functions whose results can be used by various elements throughout the detail.
    Remarks

    Each statistical function must have a unique ResultPropertyName, and becomes immutable once it has been added to the list. Only the statistical functions that are added to the StatFunctions collection of a detail can be used.

    The values used to calculate the results of a statistical function are retrieved from its statistical context. For example, if a StatRow is contained in a group's footers, its statistical context will be the group, and the results of any statistical functions displayed in the row will be calculated according to the values of the data items in the group. If the row is contained in the footers of a grid, then its statistical context is provided by a grid (through its StatContext property) and all the master data items will be used to calculate the results.

    Example
    All examples in this topic assume that the grid is bound to the Employees table of the Northwind database, unless stated otherwise
    The following example demonstrates how to explicitly define detail descriptions for the DataRelations found in the DataTable to which the grid is bound and how to calculate statistical functions for a detail description whose results will be displayed in the StatRows contained in the footer sections of the details to which the description's corresponding detail configuration will be applied.
    <Grid>
      <Grid.Resources>
         <xcdg:DataGridCollectionViewSource x:Key="cvs_employees"
                                            Source="{Binding Source={x:Static Application.Current}, 
                                                             Path=Employees}">
    
           <xcdg:DataGridCollectionViewSource.DetailDescriptions>
              <xcdg:DataRelationDetailDescription RelationName="Employee_Orders"
                                                  Title="Employee Orders">
                 <xcdg:DataRelationDetailDescription.DetailDescriptions>
                    <xcdg:DataRelationDetailDescription RelationName="Order_OrderDetails"
                                                        Title="Order Details">
                       <xcdg:DataRelationDetailDescription.ItemProperties>
                          <xcdg:DataGridItemProperty Name="UnitPrice" />
                          <xcdg:DataGridItemProperty Name="Quantity" />
                          <xcdg:DataGridItemProperty Name="Discount" />
                       </xcdg:DataRelationDetailDescription.ItemProperties>
                       <xcdg:DataRelationDetailDescription.StatFunctions>                          
                          <xcdg:SumFunction ResultPropertyName="sum_quantity"
                                            SourcePropertyName="Quantity" />
                          <xcdg:AverageFunction ResultPropertyName="average_unitprice"
                                                SourcePropertyName="UnitPrice" />
                       </xcdg:DataRelationDetailDescription.StatFunctions>
                    </xcdg:DataRelationDetailDescription>
                 </xcdg:DataRelationDetailDescription.DetailDescriptions>
              </xcdg:DataRelationDetailDescription>
           </xcdg:DataGridCollectionViewSource.DetailDescriptions>
         </xcdg:DataGridCollectionViewSource>
      </Grid.Resources>
     
      <xcdg:DataGridControl x:Name="EmployeesGrid"
                          ItemsSource="{Binding Source={StaticResource cvs_employees}}"
                          ItemsSourceName="Employee Information"
                          AutoCreateDetailConfigurations="True">
    
        <xcdg:DataGridControl.DetailConfigurations>
           <xcdg:DetailConfiguration RelationName="Employee_Orders">
              <xcdg:DetailConfiguration.DetailConfigurations>
                 <xcdg:DetailConfiguration RelationName="Order_OrderDetails">
                    <xcdg:DetailConfiguration.Footers>
                       <DataTemplate>
                          <xcdg:StatRow Background="AliceBlue">
                             <xcdg:StatCell FieldName="UnitPrice"
                                            ResultPropertyName="average_unitprice"
                                            ResultConverterParameter="f2" />
                             <xcdg:StatCell FieldName="Quantity"
                                            ResultPropertyName="sum_quantity" />                             
                          </xcdg:StatRow>
                       </DataTemplate>
                    </xcdg:DetailConfiguration.Footers>
                 </xcdg:DetailConfiguration>
              </xcdg:DetailConfiguration.DetailConfigurations>
           </xcdg:DetailConfiguration>
         </xcdg:DataGridControl.DetailConfigurations>  
       </xcdg:DataGridControl>
    </Grid>
    Requirements

    Target Platforms: Windows 11, Windows, 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also