Attaches a binding to this element, based on the provided source property name as a path qualification to the data source.
Namespace:
System.Windows
Assembly:
PresentationFramework (in PresentationFramework.dll)
Visual Basic (Declaration)
Public Function SetBinding ( _
dp As DependencyProperty, _
path As String _
) As BindingExpression
Dim instance As FrameworkElement
Dim dp As DependencyProperty
Dim path As String
Dim returnValue As BindingExpression
returnValue = instance.SetBinding(dp, _
path)
public BindingExpression SetBinding(
DependencyProperty dp,
string path
)
public:
BindingExpression^ SetBinding(
DependencyProperty^ dp,
String^ path
)
public function SetBinding(
dp : DependencyProperty,
path : String
) : BindingExpression
You cannot use methods in XAML.
This method is a convenience method for calling BindingOperations..::.SetBinding, which passes the current instance as the DependencyObject, and creates a new Binding based on the provided path parameter. This signature is more convenient if you are establishing a simple default binding. If you need to specify any binding properties to non-default conditions, or want to use a MultiBinding or PriorityBinding,you should use the SetBinding(DependencyProperty, BindingBase) signature.
The following example sets a binding using a specific path.
myDataObject = new MyData(System.DateTime.Now);
root.DataContext = myDataObject;
myText.SetBinding(TextBlock.TextProperty, "MyDataProperty");
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0
Reference
Other Resources