<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>
</StackPanel>
</Grid>
</Window>
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>
本文介绍了一个使用 WPF 进行数据绑定的例子,展示了如何将 TextBox 控件的内容长度及特定索引字符与另一个 TextBox 控件进行单向绑定。
971

被折叠的 条评论
为什么被折叠?



