IProvideValueTarget Interface

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents a service that reports situational object-property relationships for markup extension evaluation.

Namespace:  System.Windows.Markup
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Interface IProvideValueTarget
public interface IProvideValueTarget

The IProvideValueTarget type exposes the following members.

Properties

  Name Description
Public property TargetObject Gets the target object being reported.
Public property TargetProperty Gets an identifier for the target property being reported.

Top

Remarks

IProvideValueTarget represents a service that reports information regarding the object-property structure surrounding where a value converter is invoked.

Type converters and markup extensions can query for IProvideValueTarget as a service on the service context. For MarkupExtension implementations, the service context is available through the serviceProvider parameter of ProvideValue(IServiceProvider).

A scenario where IProvideValueTarget is useful is to determine the validity of your markup extension's situational usage. For example, your markup extension might implement a value deferral mechanism, but using that mechanism might only be appropriate if the target object is capable of using other components of your deferral mechanism at run time. You could check the type system characteristics of the object returned as TargetObject and confirm that the object supports your deferral technique. If so, your markup extension returns a value, and if not, your markup extension throws an exception that will surface as an inner exception for Silverlight XAML processors. A similar scenario is assuring that a particular property supports a capability, by checking type system characteristics of the TargetProperty.

Before attempting to use IProvideValueTarget, your code should include a check to verify that the service parameter itself is not null.

Important noteImportant Note:

When using the service, your code must not modify the object referenced by the TargetObject property, or other objects referenced by that object. Changes to the target could cause unexpected changes or invalidatations in the Silverlight property system.

This topic documents the Silverlight implementation of IProvideValueTarget. A parallel implementation exists in the System.Xaml DLL as part of the .NET Framework XAML Services APIs. This facilitates a general consumption of Silverlight XAML implementations and concepts, by consuming a schema context that is unique to Silverlight. For more information, see XAML Services.

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference