Xceed DataGrid for WPF v7.3 Documentation
Xceed.Wpf.DataGrid Assembly / Xceed.Wpf.DataGrid Namespace / StatCell Class
Members Example


In This Topic
    StatCell Class
    In This Topic
    Represents a cell contained in a StatRow that can display the results of a statistical function.
    Syntax
    'Declaration
     
    <TemplatePartAttribute(Name="PART_LabeledCellPanel", Type=Xceed.Wpf.DataGrid.LabeledCellPanel)>
    <DefaultPropertyAttribute("Content")>
    <ContentPropertyAttribute("Content")>
    <LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)>
    <StyleTypedPropertyAttribute(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)>
    <XmlLangPropertyAttribute("Language")>
    <UsableDuringInitializationAttribute(True)>
    <RuntimeNamePropertyAttribute("Name")>
    <UidPropertyAttribute("Uid")>
    <TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)>
    <NameScopePropertyAttribute("NameScope", System.Windows.NameScope)>
    Public Class StatCell 
       Inherits Cell
    'Usage
     
    Dim instance As StatCell
    [TemplatePart(Name="PART_LabeledCellPanel", Type=Xceed.Wpf.DataGrid.LabeledCellPanel)]
    [DefaultProperty("Content")]
    [ContentProperty("Content")]
    [Localizability(LocalizationCategory.None, Readability=Readability.Unreadable)]
    [StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)]
    [XmlLangProperty("Language")]
    [UsableDuringInitialization(true)]
    [RuntimeNameProperty("Name")]
    [UidProperty("Uid")]
    [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
    [NameScopeProperty("NameScope", System.Windows.NameScope)]
    public class StatCell : Cell 
    Remarks

    To display the results of a statistical function it is suggested to set the ResultPropertyName of the StatCell rather than binding the content.

    Although the result of a statistical function can be displayed in other elements (e.g., TextBlock), using a StatRow allows the results of statistical functions to be arranged in a similar fashion as the other cells in a grid.

    Example
    All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
    The following example demonstrates how to display the results of various statistical functions in and outside of a grid.
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
      <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key="cvs_orderdetails"
                                           Source="{Binding Source={x:Static Application.Current},
                                                            Path=OrderDetails}">
         <xcdg:DataGridCollectionViewSource.StatFunctions>
           <xcdg:CountFunction ResultPropertyName="orderid_count"
                               SourcePropertyName="OrderID"/>
           <xcdg:SumFunction ResultPropertyName="unitprice_sum"
                             SourcePropertyName="UnitPrice"/>
           <xcdg:AverageFunction ResultPropertyName="unitprice_average"
                                 SourcePropertyName="UnitPrice"/>
           <xcdg:SumFunction ResultPropertyName="quantity_sum" SourcePropertyName="Quantity"/>
         </xcdg:DataGridCollectionViewSource.StatFunctions>
         <xcdg:DataGridCollectionViewSource.GroupDescriptions>
           <xcdg:DataGridGroupDescription PropertyName="ProductID"/>      
     </xcdg:DataGridCollectionViewSource.GroupDescriptions>
        </xcdg:DataGridCollectionViewSource>
       <xcdg:StatResultConverter x:Key="valueConverter"/>
      </Grid.Resources>
      <DockPanel>
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
          <TextBlock Text="Total Orders: "/>
          <TextBlock Text="{Binding ElementName=OrderDetailsGrid,
                     Path=StatContext.orderid_count}"/>
        </StackPanel>
         <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
           <TextBlock Text="Average Unit Price: "/>
         <TextBlock Text="{Binding ElementName=OrderDetailsGrid,
                            Path=StatContext.unitprice_average,
                            Converter={StaticResource valueConverter},
                            ConverterParameter=f2}"/>
        </StackPanel>
        <xcdg:DataGridControl x:Name="OrderDetailsGrid"
                              ItemsSource="{Binding Source={StaticResource cvs_orderdetails}}"
                              DockPanel.Dock="Bottom">
          <xcdg:DataGridControl.DefaultGroupConfiguration>
            <xcdg:GroupConfiguration> 
            <xcdg:GroupConfiguration.Footers>
               <DataTemplate>
                   <xcdg:StatRow>
                   <xcdg:StatCell FieldName="UnitPrice"
                                       ResultPropertyName="unitprice_sum"/>
                   <xcdg:StatCell FieldName="Quantity" ResultPropertyName="quantity_sum"/>
                   <xcdg:StatCell FieldName="OrderID" ResultPropertyName="orderid_count"/>
                   <xcdg:StatCell FieldName="UnitPrice"
                                  ResultPropertyName="unitprice_average"
                                  ResultConverterParameter="f2"/>
                 </xcdg:StatRow>
               </DataTemplate>
             </xcdg:GroupConfiguration.Footers>
            </xcdg:GroupConfiguration>
          </xcdg:DataGridControl.DefaultGroupConfiguration>    
        </xcdg:DataGridControl>
      </DockPanel>
    </Grid>
    Inheritance Hierarchy

    System.Object
       System.Windows.Threading.DispatcherObject
          System.Windows.DependencyObject
             System.Windows.Media.Visual
                System.Windows.UIElement
                   System.Windows.FrameworkElement
                      System.Windows.Controls.Control
                         System.Windows.Controls.ContentControl
                            Xceed.Wpf.DataGrid.Cell
                               Xceed.Wpf.DataGrid.StatCell

    Requirements

    See Also