FrameworkContentElement.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 bound property.
- 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 on a Paragraph element, by creating a new custom data object, establishing that object as DataContext, and setting the binding path to a property within it.
MyData myDataObject = new MyData();
myflowdocument.DataContext = myDataObject;
introParagraph.SetBinding(Paragraph.TagProperty, "CustomData");
Dim myDataObject As New MyData()
myflowdocument.DataContext = myDataObject
introParagraph.SetBinding(Paragraph.TagProperty, "CustomData")
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 bound property.
- binding
- BindingBase
Represents a data binding.
Returns
Records the conditions of the binding. This return value can be useful for error checking.
Examples
The following example sets a binding on a Paragraph element, by creating a new Binding and setting the source to a newly built DateTime
object.
DateTime myDataObject = new DateTime();
Binding myBinding = new Binding();
myBinding.Source = myDataObject;
introParagraph.SetBinding(Paragraph.TagProperty, myBinding);
Dim myDataObject As New Date()
Dim myBinding As New Binding()
myBinding.Source = myDataObject
introParagraph.SetBinding(Paragraph.TagProperty, myBinding)
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 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기