BindingOperations.SetBinding(DependencyObject, DependencyProperty, BindingBase) BindingOperations.SetBinding(DependencyObject, DependencyProperty, BindingBase) BindingOperations.SetBinding(DependencyObject, DependencyProperty, BindingBase) BindingOperations.SetBinding(DependencyObject, DependencyProperty, BindingBase) Method

정의

BindingExpressionBase의 새 인스턴스를 만들어 지정된 바인딩 대상 속성과 연결합니다.Creates and associates a new instance of BindingExpressionBase with the specified binding target property.

public:
 static System::Windows::Data::BindingExpressionBase ^ SetBinding(System::Windows::DependencyObject ^ target, System::Windows::DependencyProperty ^ dp, System::Windows::Data::BindingBase ^ binding);
public static System.Windows.Data.BindingExpressionBase SetBinding (System.Windows.DependencyObject target, System.Windows.DependencyProperty dp, System.Windows.Data.BindingBase binding);
static member SetBinding : System.Windows.DependencyObject * System.Windows.DependencyProperty * System.Windows.Data.BindingBase -> System.Windows.Data.BindingExpressionBase
Public Shared Function SetBinding (target As DependencyObject, dp As DependencyProperty, binding As BindingBase) As BindingExpressionBase

매개 변수

target
DependencyObject DependencyObject DependencyObject DependencyObject

바인딩할 바인딩 대상입니다.The binding target of the binding.

dp
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

바인딩할 대상 속성입니다.The target property of the binding.

binding
BindingBase BindingBase BindingBase BindingBase

바인딩을 설명하는 BindingBase 개체입니다.The BindingBase object that describes the binding.

반환

지정된 속성을 사용하여 만들고 연결하는 BindingExpressionBase의 인스턴스입니다.The instance of BindingExpressionBase created for and associated with the specified property. BindingExpressionBase 클래스는 BindingExpression, MultiBindingExpressionPriorityBindingExpression의 기본 클래스입니다.The BindingExpressionBase class is the base class of BindingExpression, MultiBindingExpression, and PriorityBindingExpression.

예외

binding 매개 변수는 null일 수 없습니다.The binding parameter cannot be null.

예제

다음 예에서는 바인딩을 설정 하려면이 메서드를 사용 하는 방법을 보여 줍니다.The following example shows how to use this method to set a binding. 이 예에서 myNewBindDef 되는 Binding 바인딩을 설명 하는 개체입니다.In this example, myNewBindDef is a Binding object that describes the binding. 바인딩 대상은 myDateText, 인스턴스는 TextBlock 클래스입니다.The binding target is myDateText, an instance of the TextBlock class.

// myDatetext is a TextBlock object that is the binding target object
 BindingOperations.SetBinding(myDateText, TextBlock.TextProperty, myNewBindDef);
 BindingOperations.SetBinding(myDateText, TextBlock.ForegroundProperty, myNewBindDef);
 ' myDatetext is a TextBlock object that is the binding target object
BindingOperations.SetBinding(myDateText, TextBlock.TextProperty, myNewBindDef)
BindingOperations.SetBinding(myDateText, TextBlock.ForegroundProperty, myNewBindDef)

설명

이 메서드는의 새 인스턴스를 만듭니다는 BindingExpressionBase 지정된 된 개체의 지정 된 종속성 속성을 사용 하 여 인스턴스를 연결 합니다.This method creates a new instance of a BindingExpressionBase and associates the instance with the given dependency property of the given object. 이 메서드는 임의의에 바인딩을 연결 하는 방법은 DependencyObject 자체 SetBinding 메서드를 노출 하지 않을 수 있습니다.This method is the way to attach a binding to an arbitrary DependencyObject that may not expose its own SetBinding method.

적용 대상