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)


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


Return Value

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


Exception Condition

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


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


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


target is not of type FrameworkElement or CollectionViewSource.


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


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

Version Information


Supported in: 5, 4, 3

Silverlight for Windows Phone

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


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