Wpf “数据绑定到窗口”;s属性没有';行不通
我不知道我做错了什么,为什么我的文本没有显示出来Wpf “数据绑定到窗口”;s属性没有';行不通,wpf,data-binding,properties,Wpf,Data Binding,Properties,我不知道我做错了什么,为什么我的文本没有显示出来 <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="TheWindo
<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";
}