Jaa


Binding.Path Property

Definition

Gets or sets the path to the binding source property.

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

Property Value

The property path for the source of the binding.

Examples

The following XAML demonstrates how to set the Path using the {Binding} markup extension. For the complete code listing, see the XAML data binding sample.

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

The following XAML demonstrates how to set the Path using integer and string indexers. For the complete code listing, see the XAML data binding sample.

Note

Visual C++ component extensions (C++/CX) does not currently support indexer binding. See the sample for a workaround.

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

Remarks

The path can be a direct property of the source object, or sub-properties of that object that you traverse to using the property path syntax. For Microsoft .NET data sources, paths can also use an indexer syntax to reference specific items in a collection. For details on the property path format, see Property-path syntax.

To set the data source to be the Source object, the path should be defined with an empty string ("").

When using the {Binding} markup extension, the Path value can be set using the argument immediately following the {Binding part of the extension usage, you don't need to explicitly include Path=. For example, {Binding Albums} sets the Path value of that binding to be a PropertyPath constructed from the string "Albums" (no other Binding properties are set).

Most usages of Path involve setting its value. For scenarios where you are getting the value to examine the properties of an existing binding, the PropertyPath.Path value contains the string that represents the path.

You can't set the property values of a Binding object after that binding has been attached to a target element and target property. If you attempt this you'll get a run-time exception.

Applies to

See also