我想动态更改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
在我的应用程序中没有显示“设置”。这里有什么问题?