แก้ไข

แชร์ผ่าน


BindingBase.ProvideValue(IServiceProvider) Method

Definition

Returns an object that should be set on the property where this binding and extension are applied.

public:
 override System::Object ^ ProvideValue(IServiceProvider ^ serviceProvider);
public override sealed object ProvideValue (IServiceProvider serviceProvider);
override this.ProvideValue : IServiceProvider -> obj
Public Overrides NotOverridable Function ProvideValue (serviceProvider As IServiceProvider) As Object

Parameters

serviceProvider
IServiceProvider

The object that can provide services for the markup extension. May be null.

Returns

The value to set on the binding target property.

Remarks

This implementation provides the base syntax support for binding through Extensible Application Markup Language (XAML) for all provided practical derived classes (Binding, PriorityBinding, and MultiBinding).

The BindingBase class implementation of this method is expected to return an expression object that is the result of a binding. Binding a property works by targeting a given DependencyProperty on a given DependencyObject. These two pieces of information are transmitted by querying for an IProvideValueTarget implementation on the serviceProvider, which the WPF XAML reader makes available during parsing of a binding. This base class implementation is responsible for checking for a valid DependencyProperty and DependencyObject. If these are found, the actual implementation of returning a binding expression falls to various derived classes, as implemented by having the base class call an internal abstract method. Otherwise, the extension returns the binding object itself. Returning the binding itself results in a type mismatch error, but this should not occur under normal circumstances.

Important

Because the syntax for binding through XAML as implemented in this method relies on implementing an internal override, and because BindingBase.ProvideValue itself is sealed, a custom binding class that derives from BindingBase will not function correctly as a XAML markup extension.

Applies to