BindingOperations.GetBindingExpression 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 개체의 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 입니다.
개체를 검색할 바인딩 대상 속성입니다 BindingExpression .
반환
BindingExpression 지정된 속성과 연결된 개체이거나 null 없는 경우입니다. 개체가 PriorityBindingExpression 속성 ActiveBindingExpression 에 설정된 경우 반환됩니다.
예외
및 dp 매개 변수는 target 을(를) 사용할 null수 없습니다.
예제
다음 예제에서는 메서드를 Click 사용하여 GetBindingExpression 바인딩 소스 개체에 액세스하기 위해 속성을 가져온 BindingExpression 다음 호출 DataItem 하는 이벤트 처리기의 구현을 보여줍니다.
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 바인딩 원본과 바인딩 대상 간의 연결을 유지합니다. 이 정적 메서드를 BindingExpression 호출하거나 데이터 바인딩 FrameworkElement 또는 FrameworkContentElement 개체에서 메서드를 GetBindingExpression 호출하여 개체를 가져올 수 있습니다.