2014-10-19 32 views
0

wpf應用程序的新手。我試圖執行這個代碼,但標籤總是空白不管我在文本框中輸入:爲什麼TextBox無法綁定到我的XAML代碼中的Label?

<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> 

回答

1

這是因爲textbox3textBox3有不同的名稱。只是改變的情況下,它會工作

+0

嘆息......它始終是我的邏輯錯誤。非常感謝。 – Jaja 2014-10-19 00:55:36

0
<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> 
相關問題