Long Binding Path


   
   

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:s="clr-namespace:System;assembly=mscorlib"
      FontSize="12pt"
      Name="page">
    <StackPanel>
        <TextBlock HorizontalAlignment="Center">
            First element in StackPanel
        </TextBlock>

        <ListBox HorizontalAlignment="Center"
                 Margin="24">
            <ListBoxItem>First</ListBoxItem>
            <ListBoxItem>Second</ListBoxItem>
            <ListBoxItem>Third</ListBoxItem>
            <ListBoxItem>Fourth</ListBoxItem>
            <ListBoxItem>Fifth</ListBoxItem>
        </ListBox>

        <TextBlock HorizontalAlignment="Center">
            <Label Content="Number of characters in third ListBox item = " />
            <Label Content="{Binding ElementName=page, Path=Content.Children&#91;1&#93;.Items&#91;2&#93;.Content.Length}" />
            <LineBreak />
            <Label Content="Number of characters in selected item = " />
            <Label Content="{Binding ElementName=page,Path=Content.Children&#91;1&#93;.SelectedItem.Content.Length}" />
        </TextBlock>
    </StackPanel>
</Page>