2013-08-26 67 views
-1

我想不出什麼我做錯了,爲什麼我的文字顯示不出來數據綁定到一個窗口「的財產不工作

<Window x:Class="Test" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Test" Height="300" Width="300" x:Name="TheWindow"> 

    <TextBlock Text="{Binding ElementName=TheWindow,Path=TestObject, Mode=OneTime}" FontSize="12"></TextBlock> 

,窗口後面的代碼:

public partial class Test : Window 
{ 
    public Test() 
    { 
     InitializeComponent(); 
    } 

    public const string TestObject = "I just want to be shown"; 
} 

}

回答