Attaches a binding to a FrameworkElement, using the provided binding object.
Syntax
Parameters
- dp
-
Type: DependencyProperty
The dependency property identifier of the property that is data bound.
- binding
-
Type: BindingBase
The binding to use for the property.
Remarks
This method is a convenience method that simply calls BindingOperations.SetBinding, passing the current instance as the target parameter.
The type of the binding parameter is BindingBase for compatibility reasons, but in the Windows Runtime you always pass a Binding instance. Binding is derived from BindingBase.
The dp parameter takes a dependency property identifier. For more info on dependency properties and how a DependencyProperty value serves as the identifier, see Dependency properties overview.
Examples
This example establishes a binding to a dependency property on an object by calling SetBinding.
// 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);
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 1/31/2013