简体   繁体   English

用C#代码转换此XAML标签内容绑定?

[英]C# code to convert this XAML label content binding?

Hi I have a label which is binded to a resource file. 嗨,我有一个绑定到资源文件的标签。 The label is as follows: 标签如下:

<Label Name="LabelName" Content="{x:Static p:Resources.LabelName}" />

How would I convert this to C# code so I can generate the label dynamically? 如何将其转换为C#代码,以便可以动态生成标签?

I tried doing 我试着做

LabelName.SetBinding(ContentProperty, "{x:Static p:Resources.LabelName}");

but the label content shows up blank on the screen. 但是标签内容在屏幕上显示为空白。

Thank you. 谢谢。

LabelName.Content = WPFLocalization.Properties.Resources.LabelName;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM