簡體   English   中英

為什么TextBox不綁定到我的XAML代碼中的Label?

[英]Why doesn't TextBox bind to Label in my XAML code?

wpf應用程序的新功能。 我嘗試實現此代碼,但是無論我在文本框中輸入什么,標簽始終為空:

<Window x:Class="Mufu.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Muf(u)" Height="350" Width="525">
<Grid>
    <TextBox Height="23" HorizontalAlignment="Left" Margin="100,200,0,0" Name="textBox3" VerticalAlignment="Top" Width="124" />
    <Label Content="{Binding ElementName=textbox3, Path=Text}"  Height="48" HorizontalAlignment="Center" Margin="0,30,0,0" Name="label4" VerticalAlignment="Top" Width="445" FontSize="26" />
</Grid>

這是因為textbox3textBox3是不同的名稱。 只需更改大小寫,它將起作用

<Stackpanel>
    <TextBox Height="23" HorizontalAlignment="Left" Margin="100,200,0,0" Name="textBox3" VerticalAlignment="Top" Width="124" />
    <Label Content="{Binding ElementName=textbox3, Path=Text}"  Height="48" HorizontalAlignment="Center" Margin="0,30,0,0" Name="label4" VerticalAlignment="Top" Width="445" FontSize="26" />
</Stackpanel>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM