다음을 통해 공유


BindingOperations.GetBindingExpression 메서드

정의

지정된 개체의 지정된 바인딩 대상 속성과 연결된 BindingExpression 개체를 반환합니다.

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

매개 변수

target
DependencyObject

dp 바인딩 대상 개체입니다.

dp
DependencyProperty

BindingExpression 개체를 검색할 바인딩 대상 속성입니다.

반환

지정된 속성과 연결된 BindingExpression 개체이거나 없는 경우 null. 속성에 PriorityBindingExpression 개체가 설정되면 ActiveBindingExpression 반환됩니다.

예외

targetdp 매개 변수는 null수 없습니다.

예제

다음 예제에서는 GetBindingExpression 메서드를 사용하여 BindingExpression 가져온 다음 DataItem 속성을 호출하여 바인딩 소스 개체에 액세스하는 Click 이벤트 처리기의 구현을 보여 있습니다.

TextBlock SavingsText 바인딩 대상 개체이고 Text 바인딩 대상 속성입니다.

private void OnRentRaise(Object sender, RoutedEventArgs args)
{
  // Update bills
  System.Random random = new System.Random();
  double i = random.Next(10);
  BindingExpression bindingExpression =
    BindingOperations.GetBindingExpression(SavingsText, TextBlock.TextProperty);
  SDKSample.NetIncome sourceData = (SDKSample.NetIncome) bindingExpression.DataItem;
  sourceData.Rent = (int)((1 + i / 100) * (double)sourceData.Rent);
}
Private Sub OnRentRaise(ByVal sender As Object, ByVal args As RoutedEventArgs)
    Dim _random As New System.Random()
    Dim num1 As Double = _random.Next(10)
    Dim expression1 As BindingExpression = BindingOperations.GetBindingExpression(Me.SavingsText, TextBlock.TextProperty)
    Dim income1 As NetIncome = DirectCast(expression1.DataItem, NetIncome)
    income1.Rent = CInt(((1 + (num1 / 100)) * income1.Rent))
End Sub

설명

BindingExpression 개체는 바인딩 소스와 바인딩 대상 간의 연결을 유지 관리합니다. 이 정적 메서드를 호출하거나 데이터 바인딩된 FrameworkElement 또는 FrameworkContentElement 개체에서 GetBindingExpression 메서드를 호출하여 BindingExpression 개체를 가져올 수 있습니다.

적용 대상

추가 정보