0
我有我的看法,我用它来从不同的语言文字得到的一个LabelService类的实例。
这就要求我的代码在后台如下填充在TextBlock中文字:
XAML:
<TextBlock Name="txtExample" Grid.Row="0" Margin="5,5,5,5"/>
C#:
// 'this' refers to the current class, the namespace of which is used to navigate
// through an XML labels file to find the correct label
string label = _labelService.GetSpecificLabel(this, txtExample.Name).Label
txtExample.Text = label;
问题:
是否有可能我h此功能:
_labelService.GetSpecificLabel(this, txtExample.Name).Label
可在XAML?
补充信息:
只是为了解释什么,我使用命名空间导航标签XML的意思是:
假设类的定义如下,在命名空间
namespace My.App.Frontend
{
public class MainWindow
{
string label = _labelService.GetSpecificLabel(this, txtExample.Name).Label
}
}
相应的XML将是
<My>
<App>
<Frontend>
<MainWindow>
<txtExample label="I am the example text" />
</MainWindow>
</Frontend>
</App>
</My>