Microsoft Silverlight will reach end of support after October 2021. Learn more.
Assembly: System.Windows (in System.Windows.dll)
'Declaration Public Function SetBinding ( _ dp As DependencyProperty, _ binding As Binding _ ) As BindingExpressionBase
public BindingExpressionBase SetBinding( DependencyProperty dp, Binding binding )
The dependency property identifier of the property that is data bound.
The binding to use for the property.
The returned binding expression is not necessary for many of the common binding scenarios, but is potentially useful for scenarios such as updating the source manually, or getting references to the parent Binding after the expression is created. The BindingExpressionBase class is a base class. In most cases you should attempt to cast the return value to BindingExpression, which is the class that implements the relevant API for the mentioned update or Binding parent scenarios.
The following example establishes a binding to a dependency property on an object by calling SetBinding.
'Create the source string Dim s As String = "Hello" 'Create the binding description Dim b As New Binding("") b.Mode = BindingMode.OneTime b.Source = s 'Attach the binding to the target MyText.SetBinding(TextBlock.TextProperty, b)
//Create the source string string s = "Hello"; //Create the binding description Binding b = new Binding(""); b.Mode = BindingMode.OneTime; b.Source = s; //Attach the binding to the target MyText.SetBinding(TextBlock.TextProperty, b);
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.