WPF Binding Path妙用

<Window x:Class="XamlTest.Window9"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window9" Height="300" Width="300">
    <Grid>
        <StackPanel>

            <TextBox Text="{Binding Path=Text.Length, ElementName=txt2, Mode=OneWay}"></TextBox>

//必须指定Mode为OneWay否则无法编译通过

<TextBox Text="{Binding Path=Text.[3], ElementName=txt2, Mode=OneWay}"></TextBox>

//绑定到索引

            <TextBox Name="txt2"></TextBox>
        </StackPanel>
    </Grid>
</Window>
原文地址:https://www.cnblogs.com/dxmfans/p/9434621.html