バックグラウンド:
ビューに、さまざまな言語からテキストを取得するために使用する 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;
質問:
この機能を使用することは可能ですか:
_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>