Binding.Path 속성

정의

바인딩 소스 속성의 경로를 가져오거나 설정합니다.

public:
 property PropertyPath ^ Path { PropertyPath ^ get(); void set(PropertyPath ^ value); };
PropertyPath Path();

void Path(PropertyPath value);
public PropertyPath Path { get; set; }
var propertyPath = binding.path;
binding.path = propertyPath;
Public Property Path As PropertyPath
<Binding Path="propertyPath"/>

속성 값

바인딩의 원본에 대한 속성 경로입니다.

예제

다음 XAML에서는 {Binding} 태그 확장을 사용하여 경로를 설정하는 방법을 보여 줍니다. 전체 코드 목록은 XAML 데이터 바인딩 샘플을 참조하세요.

<StackPanel Margin="5">

  <TextBlock Text="Name:" Style="{StaticResource DescriptionTextStyle}" 
    Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"/>

  <TextBox Text="{Binding Path=Name, Mode=TwoWay}" 
    Width="350" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"/>

  <TextBlock Text="Organization:" Style="{StaticResource DescriptionTextStyle}" 
    Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"/>

  <!-- You can omit the 'Path=' portion of the binding expression. -->
  <TextBox Text="{Binding Organization, Mode=TwoWay}" Width="350" 
    Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"/>

</StackPanel>

다음 XAML에서는 정수 및 문자열 인덱서를 사용하여 경로를 설정하는 방법을 보여 줍니다. 전체 코드 목록은 XAML 데이터 바인딩 샘플을 참조하세요.

참고

Visual C++ 구성 요소 확장(C++/CX)은 현재 인덱서 바인딩을 지원하지 않습니다. 해결 방법은 샘플을 참조하세요.

<StackPanel>

  <StackPanel Orientation="Horizontal">

    <TextBlock Text="Team name:" 
      Style="{StaticResource DescriptionTextStyle}" 
      Margin="5" FontWeight="Bold"/>

    <TextBlock Text="{Binding Path=[3].Name}" 
      Style="{StaticResource DescriptionTextStyle}" Margin="5" />

  </StackPanel>

  <StackPanel Orientation="Horizontal">

    <TextBlock Text="Team manager:" 
      Style="{StaticResource DescriptionTextStyle}" 
      Margin="5" FontWeight="Bold"/>

    <TextBlock Text="{Binding Path=[3][Gaffer]}" 
      Style="{StaticResource DescriptionTextStyle}" Margin="5"/>

  </StackPanel>

</StackPanel>

설명

경로는 원본 개체의 직접 속성이거나 속성 경로 구문을 사용하여 트래버스하는 해당 개체의 하위 속성일 수 있습니다. Microsoft .NET 데이터 원본의 경우 경로는 인덱서 구문을 사용하여 컬렉션의 특정 항목을 참조할 수도 있습니다. 속성 경로 형식에 대한 자세한 내용은 속성 경로 구문을 참조하세요.

데이터 원본을 Source 개체로 설정하려면 빈 문자열("")을 사용하여 경로를 정의해야 합니다.

{Binding} 태그 확장을 사용하는 경우 확장 사용의 바로 다음 {Binding 인수를 사용하여 경로 값을 설정할 수 있습니다. 명시적으로 을 포함Path=할 필요가 없습니다. 예를 들어 는 {Binding Albums} 해당 바인딩의 Path 값을 문자열 "Albums"에서 생성된 PropertyPath 로 설정합니다(다른 바인딩 속성은 설정되지 않음).

Path의 대부분의 사용에는 해당 값 설정이 포함됩니다. 기존 바인딩의 속성을 검사하는 값을 가져오는 시나리오의 경우 PropertyPath.Path 값에는 경로를 나타내는 문자열이 포함됩니다.

바인딩이 대상 요소 및 대상 속성에 연결된 후에는 Binding 개체의 속성 값을 설정할 수 없습니다. 이 작업을 시도하면 런타임 예외가 발생합니다.

적용 대상

추가 정보