When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.
Assembly: System.Xaml (in System.Xaml.dll)
'Declaration Public MustOverride Function ProvideValue ( _ serviceProvider As IServiceProvider _ ) As Object
- Type: System.IServiceProvider
A service provider helper that can provide services for the markup extension.
Return ValueType: System.Object
The object value to set on the property where the extension is applied.
When a XAML processor processes a type node and member value that is a markup extension, it invokes the method of that markup extension and writes the result into the object graph or serialization stream. The XAML object writer passes service context to each such implementation through the serviceProvider parameter.
See "Notes to Implementers" section for more information on how to implement in a custom markup extension.
WPF Usage Notes
Common services returned by the default service provider that is typically available to a custom or existing MarkupExtension implementation include the following primary services.
IProvideValueTarget reports the object reference and a property identifier from the context where the markup extension is used
IXamlTypeResolver exposes a service that parallels the general XAML object writing behavior that can provide a Type based on a XAML type name. The name can optionally include a prefix for a mapped XAML namespace.
IXamlSchemaContextProvider exposes the active XAML schema context directly. From the reported XamlSchemaContext, you can obtain XAML schema context information such as how assemblies are mapped for type support, preferred prefix in assemblies, lists of each XamlType in an assembly, and so on.
Other services available for more specialized markup extension scenarios include:
Potentially, implementations of can ignore the serviceProvider parameter. This is viable for some basic scenarios, where no context at all is required for returning a value.
In typical usage, the .NET Framework XAML Services and the implemented XAML object writers will provide a service provider to all value converter methods it invokes during XAML processing. However, for robustness, you should provide code paths for null values both for the service provider itself and for any requested service. Null values might occur if your markup extension is applied in some circumstance where the typical service support provided by a XAML parser infrastructure is not available.
For more information on available services from the XAML service provider context and how to use them, see Type Converters and Markup Extensions for XAML.
Implementations that require a certain service to return a value are expected to throw exceptions if that service is not available. The recommended exception to throw is InvalidOperationException.
You may also throw exceptions if one of the arguments that your custom markup extension needs in order to provide a value is null, is invalid for its data type, or does not contain a value that your markup extension is capable of processing. The recommended exception to throw is InvalidOperationException.
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
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.