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>