我正在做一个简单的DataBinding
应用程序WPF
。在这个应用程序中,我在TextBox
命名中输入的任何内容都txtName
应该出现在Label
. 为此,我使用了绑定WPF
,但它没有被绑定。
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="315*" />
<ColumnDefinition Width="188*" />
</Grid.ColumnDefinitions>
<TextBox Height="23" HorizontalAlignment="Left"
Margin="79,12,0,0" Name="txtName"
VerticalAlignment="Top" Width="120" />
<Label Height="28" HorizontalAlignment="Left"
Margin="22,12,0,0" Name="label1"
VerticalAlignment="Top" Width="42"
Content="Name"/>
<TextBox Height="23" HorizontalAlignment="Left"
Margin="79,56,0,0" Name="txtSirName"
VerticalAlignment="Top" Width="120" />
<Label Content="SirName" Height="28"
HorizontalAlignment="Left" Margin="12,56,0,0"
Name="label2" VerticalAlignment="Top" Width="52" />
<!-- Following is the label which I bound -->
<Label Content="{Binding ElementName=txtName,Path=text}"
Height="28" HorizontalAlignment="Left" Margin="47,112,0,0"
Name="label3" VerticalAlignment="Top" Width="171" />
</Grid>
我是新手WPF
。请指导我。