Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

BindingBase.ProvideValue Method (IServiceProvider)

 

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

Namespace:   System.Windows.Data
Assembly:  PresentationFramework (in PresentationFramework.dll)

public override sealed object ProvideValue(
	IServiceProvider serviceProvider
)

Parameters

serviceProvider
Type: System.IServiceProvider

The object that can provide services for the markup extension. May be null; see the Remarks section for more information.

Return Value

Type: System.Object

The value to set on the binding target property.

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.

System_CAPS_importantImportant

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.

.NET Framework
Available since 3.0
Silverlight
Available since 5.0
Return to top
Show:
© 2016 Microsoft