FrameworkElement.SetBinding Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Attaches a binding to this element for the specified dependency property.
Overloads
SetBinding(DependencyProperty, String) |
Attaches a binding to this element, based on the provided source property name as a path qualification to the data source. |
SetBinding(DependencyProperty, BindingBase) |
Attaches a binding to this element, based on the provided binding object. |
SetBinding(DependencyProperty, String)
Attaches a binding to this element, based on the provided source property name as a path qualification to the data source.
public:
System::Windows::Data::BindingExpression ^ SetBinding(System::Windows::DependencyProperty ^ dp, System::String ^ path);
public System.Windows.Data.BindingExpression SetBinding (System.Windows.DependencyProperty dp, string path);
member this.SetBinding : System.Windows.DependencyProperty * string -> System.Windows.Data.BindingExpression
Public Function SetBinding (dp As DependencyProperty, path As String) As BindingExpression
Parameters
Identifies the destination property where the binding should be established.
- path
- String
The source property name or the path to the property used for the binding.
Returns
Records the conditions of the binding. This return value can be useful for error checking.
Examples
The following example sets a binding using a specific path.
myDataObject = new MyData(System.DateTime.Now);
root.DataContext = myDataObject;
myText.SetBinding(TextBlock.TextProperty, "MyDataProperty");
myDataObject = New MyData(Date.Now)
root.DataContext = myDataObject
myText.SetBinding(TextBlock.TextProperty, "MyDataProperty")
Remarks
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.
Applies to
SetBinding(DependencyProperty, BindingBase)
Attaches a binding to this element, based on the provided binding object.
public:
System::Windows::Data::BindingExpressionBase ^ SetBinding(System::Windows::DependencyProperty ^ dp, System::Windows::Data::BindingBase ^ binding);
public System.Windows.Data.BindingExpressionBase SetBinding (System.Windows.DependencyProperty dp, System.Windows.Data.BindingBase binding);
member this.SetBinding : System.Windows.DependencyProperty * System.Windows.Data.BindingBase -> System.Windows.Data.BindingExpressionBase
Public Function SetBinding (dp As DependencyProperty, binding As BindingBase) As BindingExpressionBase
Parameters
Identifies the property where the binding should be established.
- binding
- BindingBase
Represents the specifics of the data binding.
Returns
Records the conditions of the binding. This return value can be useful for error checking.
Remarks
This method is a convenience method for calling BindingOperations.SetBinding, which passes the current instance as the DependencyObject.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기