Class StaticExtension
Implements a markup extension that returns static field and property references.
Inheritance
Namespace: Telerik.Windows.Controls
Assembly: Telerik.Windows.Controls.dll
Syntax
public class StaticExtension : MarkupExtension
Constructors
StaticExtension()
Initializes a new instance of the StaticExtension class.
Declaration
public StaticExtension()
StaticExtension(String)
Initializes a new instance of the StaticExtension class using the provided member string.
Declaration
public StaticExtension(string member)
Parameters
System.String
member
A string that identifies the member to make a reference to. This string uses the format prefix:typeName.fieldOrPropertyName. |
Remarks
The member value is not evaluated when you set it. If the initial value is not null, then the value is accepted. The actual parsing and evaluation of the member value is deferred until ProvideValue(IServiceProvider) is called when a XAML reader processes an extension usage. At that time, XAML schema context informs the type mapping and the value can be obtained.
Properties
Member
Gets or sets a member name string that is used to resolve a static field or property based on the service-provided type resolver.
Declaration
public string Member { get; set; }
Property Value
System.String
|
Remarks
The string for Member typically uses the format prefix:typeName.fieldOrPropertyName. The string can also specify only the member name, so long as MemberType is also supplied, but note that this technique will not support XML namespaces and prefixes; it is working at the type system level. This value is not evaluated when you set it; so long as the value is not null it will be accepted. The actual parsing and evaluation of the value is deferred until ProvideValue(IServiceProvider) is called during parsing. Under the normal scenario of use by the Silverlight XAML processor, the XAML processor passes a type resolver for CLR types as part of its service contract, and this resolver is used on the ProvideValue call.
MemberType
Gets or sets the System.Type that defines the static member to return.
Declaration
public Type MemberType { get; set; }
Property Value
System.Type
|
Remarks
It can return a static member based on Member being the simple member name and its owning type supplied as MemberType, rather than Member providing a full name in the form type.member. The type resolver still acts, but in this case the Member and MemberType are basically combined: memberFullName = MemberType.FullName + "." + Member. Note that this technique will not support XAML namespaces and prefixes; it is working against the backing type system, not the XAML type system.
Methods
ProvideValue(IServiceProvider)
Returns an object value to set on the property where you apply this extension. For StaticExtension, the return value is the static value that is evaluated for the requested static member.
Declaration
public override object ProvideValue(IServiceProvider serviceProvider)
Parameters
System.IServiceProvider
serviceProvider
An object that can provide services for the markup extension. The service provider is expected to provide a service that implements a type resolver (System.Windows.Markup.IXamlTypeResolver). |
Returns
System.Object
The static value to set on the property where the extension is applied. |
Remarks
This method supports XAML language features and is generally not intended to be called directly. This implementation relies on services that are based on the passed serviceProvider. serviceProvider must not be null. The serviceProvider object is expected to return a service for System.Windows.Markup.IXamlTypeResolver. Under the normal scenario of use by the default XAML readers, a suitable service provider is available. StaticExtension supports an alternate mode whereby it can return a static member based on Member being the simple member name and its owning type supplied as MemberType, rather than Member providing a full name in the form type.member. The type resolver still acts, but in this case the Member and MemberType are basically combined: memberFullName = MemberType.FullName + "." + Member.