I have a TextBox inside a DataTemplate in my XAML:
<DataTemplate x:Key="aproved" >
<StackPanel Orientation="Vertical" Width="70" Height="70" VerticalAlignment="Center" HorizontalAlignment="Center" >
<Image Source="/PF;component/Images/checked_checked.png" Width="50" Height="50"></Image>
<TextBlock Name="tbAproved" HorizontalAlignment="Center" Text="Aproved" />
</StackPanel>
</DataTemplate>
I want to translate the text "Aproved" in my TextBlock using my translator class (LanguageManager), who is responsable to get strings from my resources files:
public class LanguageManager {
public static String GetString(String resourceName) {
if (Singleton.Instance().IdLanguage == 2) {
return ResourceEnglish.ResourceManager.GetString(resourceName);
} else {
return ResourcePortuguese.ResourceManager.GetString(resourceName);
}
}
}
So in my textbox I was trying to do something like this:
<TextBlock Name="tbAproved" HorizontalAlignment="Center" Text="LanguageManager.GetString('resourceName')"/>
Geting the string direcly from my class and passing a parameter with the resourceName.
I am using Silverlight 4.
Is there any way to do this? I have to do something complety different in my code?
You can do it as simple as this:
If you want use Binding in XAML (recommended):
Set DataContext to View Model that has ApprovedLabel Property: