BindingOperations.SetBinding 메서드

정의

BindingExpressionBase의 새 인스턴스를 만들어 지정된 바인딩 대상 속성과 연결합니다.

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

바인딩할 바인딩 대상입니다.

dp
DependencyProperty

바인딩할 대상 속성입니다.

binding
BindingBase

바인딩을 설명하는 BindingBase 개체입니다.

반환

BindingExpressionBase

지정된 속성을 사용하여 만들고 연결하는 BindingExpressionBase의 인스턴스입니다. BindingExpressionBase 클래스는 BindingExpression, MultiBindingExpressionPriorityBindingExpression의 기본 클래스입니다.

예외

binding 매개 변수는 null일 수 없습니다.

예제

다음 예제에서는 이 메서드를 사용하여 바인딩을 설정하는 방법을 보여 있습니다. 이 예제에서는 myNewBindDef 바인딩을 Binding 설명하는 개체입니다. 바인딩 대상은 myDateText클래스의 인스턴스입니다 TextBlock .

  // 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)

설명

이 메서드는 a의 새 인스턴스를 BindingExpressionBase 만들고 지정된 개체의 지정된 종속성 속성과 인스턴스를 연결합니다. 이 메서드는 자체 SetBinding 메서드를 노출하지 않을 수 있는 임의 DependencyObject 에 바인딩을 연결하는 방법입니다.

적용 대상