Represents a converter that can be used to format the result of a statistical function, as well as display a user-friendly message when an exception occurs within the function during the calculation of its result.
The messages returned by a StatResultConverter when an exception occurs during the calculation of a statistical function's result depend on the type of the exception that was thrown. The following table provides a list of exceptions for which default messages have been provided:
Composite format strings use braces ("{}") to identify place-holders, which causes an issue when providing a format string to a StatResultConverter in XAML; therefore, the StatResultConverter supports square brackets ("[]") as a substitute for braces. For example, if normally {0:#0.0} would have been used, it would be replaced with [#0.0] when using a StatResultConverter. If braces are preferred, the format string must be preceded with a closing brace (e.g., ConverterParameter={}{0:#0.0}}).
When using square brackets, the 0: that represents the place-holder must be omitted otherwise an exception will be thrown.
Example
All examples in this topic assume that the grid is bound to the Orders or Employees tables 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.The following example demonstrates how to change the statistical context of a TextBlock that displays the results of a statistical function when the current item is changed. The statistical context of the TextBlock will be changed in the grid's PropertyChanged event handler by using the GetParentGroupFromItem method to retrieve the current group and set it as the new statistical context.
To simplify the code below, the DataContext of the StackPanel could have been modified rather than the DataContext of each TextBlock.
The implementation of the PropertyChanged event handler is located below.The following code provides the implementation of the PropertyChanged event handler.The following code provides the implementation of the PropertyChanged event handler.The following example demonstrates how to create a custom data template that will be used in the footers of the first-level groups to display the results of various statistical functions.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.
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