小编Luc*_*cas的帖子

TextBlock 中的绑定在 WPF 中不起作用

我想动态更改TextBlock班级中的文本。

XAML 代码

<TextBlock Name="Footer_text"  Text=""/>
Run Code Online (Sandbox Code Playgroud)

C#

string footerMainMenuText = "Setting";
Binding  set = new Binding("");
set.Mode = BindingMode.OneWay;
set.Source = footerMainMenuText;
Footer_text.DataContext = footerMainMenuText;
Footer_text.SetBinding(TextBlock.TextProperty, set);
Run Code Online (Sandbox Code Playgroud)

我检查了最后一行,并且Footer_text.Text设置正确。( Footer_text.Text="Setting"),但TextBlock在我的应用程序中没有显示“设置”。这里有什么问题?

c# data-binding wpf textblock

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

data-binding ×1

textblock ×1

wpf ×1