New to Telerik UI for WPF? Start a free 30-day trial

Provides the context for custom functions in the ExpressionParser.

Definition

Namespace:Telerik.Expressions

Assembly:Telerik.Windows.Data.dll

Syntax:

C#
public class ExpressionFunctionContext

Inheritance: objectExpressionFunctionContext

Constructors

Initializes a context with the specified allowlist of custom expression functions.

C#
public ExpressionFunctionContext(ExpressionFunctionRegistry functionRegistry)
Parameters:functionRegistryExpressionFunctionRegistry

The registry used to resolve custom expression functions.

Exceptions: ArgumentNullException

functionRegistry is null.

Only explicitly registered custom functions can be called. Methods added to a derived context must be registered before expressions are parsed. Use CreateWithBuiltInFunctions() to retain WPF's built-in expression functions.

Example:
C#
public sealed class MyExpressionFunctionContext : ExpressionFunctionContext
{
public MyExpressionFunctionContext() : base(CreateRegistry()) { }

public double Pi() { return Math.PI; }

private static ExpressionFunctionRegistry CreateRegistry()
{
ExpressionFunctionRegistry registry = ExpressionFunctionRegistry.CreateWithBuiltInFunctions();
registry.AddGlobalFunction(typeof(MyExpressionFunctionContext), nameof(Pi), Type.EmptyTypes);
return registry;
}
}

Properties

Gets or sets the default expression context used for registered global expression functions.

C#
public static ExpressionFunctionContext Context { get; set; }

Custom functions must be registered through FunctionRegistry before they can be used.

Gets the registry used to explicitly register custom global and receiver expression functions.

C#
public ExpressionFunctionRegistry FunctionRegistry { get; }