1 out of 2 rated this helpful - Rate this topic

Binding.Path property

Gets or sets the path to the binding source property.

Syntax


public PropertyPath Path { get; set; }


<Binding Path="propertyPath"/>

XAML Values

propertyPath

A string that describes a property on the binding source. This can be a simple property name, or a "dotted-down" property path to a sub-property.

Property value

Type: PropertyPath

The property path for the source of the binding.

Remarks

The path can be a direct property of the source object or sub-properties.

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

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

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml.Data
Windows::UI::Xaml::Data [C++]

Metadata

Windows.winmd

See also

Binding
XAML data binding sample
Data binding overview

 

 

Build date: 12/4/2012

© 2013 Microsoft. All rights reserved.