BindingOperations.SetBinding Method

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

Creates and associates a new BindingExpressionBase with the specified binding target property.

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

Syntax

'Declaration
Public Shared Function SetBinding ( _
    target As DependencyObject, _
    dp As DependencyProperty, _
    binding As BindingBase _
) As BindingExpressionBase
public static BindingExpressionBase SetBinding(
    DependencyObject target,
    DependencyProperty dp,
    BindingBase binding
)

Parameters

Return Value

Type: System.Windows.Data.BindingExpressionBase
An object that contains information about the binding.

Exceptions

Exception Condition
ArgumentNullException

target is nulla null reference (Nothing in Visual Basic).

-or-

dp is nulla null reference (Nothing in Visual Basic).

-or-

binding is nulla null reference (Nothing in Visual Basic).

ArgumentException

target is not of type FrameworkElement or CollectionViewSource.

-or-

target is of type CollectionViewSource and binding has a Source value of nulla null reference (Nothing in Visual Basic).

-or-

binding has a Mode value of TwoWay and an empty Path value.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

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