【发布时间】:2023-06-09 06:03:01
【问题描述】:
我在 wpf/xaml 中的绑定有一些问题。有这个简单的文件:
<Window x:Class="test.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBlock Height="21" Foreground="Black" Margin="74,98,84,0" Name="textBlock1" VerticalAlignment="Top" Text="{Binding MyText}" />
</Grid>
</Window>
我想将文本块的内容绑定到我的属性“MyText”。我的代码如下所示:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
public string MyText
{
get { return "This is a test"; }
}
}
总而言之很简单,但是当我启动文本块时没有内容 - 怎么办?
【问题讨论】:
-
更新:我什至没有在属性处获得断点