cs代码:
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ContentGrid.DataContext = this;
this.Path = "数据绑定";
}
public string Path { get; set; }
}
XAML代码:
<Grid x:Name="ContentGrid">
<TextBlock Text="{Binding Path}"></TextBlock>
</Grid>
wpf中如何在xaml中绑定cs中类的属性
时间: 2024-10-18 06:45:25