<TextBlock Height="19" HorizontalAlignment="Left" Margin="280,0,0,0"
Text="{Binding Source={StaticResource IssuerStringLibrary}, Converter={StaticResource Localizer}, ConverterParameter=properties_lbl_description}" TextWrapping="Wrap" VerticalAlignment="Top" />
public class Localizer : System.Windows.Data.IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
var reader = (IStringLibrary)value;
string resourceValue;
string resourceName = parameter as string;
if (!string.IsNullOrEmpty(resourceName))
{
resourceValue = reader.Get(resourceName);
}
else
{
resourceValue = "ConverterParameter missing in Binding tag"; //ERROR
}
return resourceValue;
}
catch
{
return "Localization Configuration Error";
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
public static string Get(object stringLibrary, string resourceName)
{
try
{
string resourceValue;
var reader = (IStringLibrary)stringLibrary;
if (!string.IsNullOrEmpty(resourceName))
{
resourceValue = reader.Get(resourceName);
}
else
{
resourceValue = "Invalid resourceName"; //ERROR
}
return resourceValue;
}
catch
{
return "Localization Configuration Error";
}
}
#endregion
}
public class Localizer : System.Windows.Data.IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
var reader = (IStringLibrary)value;
string resourceValue;
string resourceName = parameter as string;
if (!string.IsNullOrEmpty(resourceName))
{
resourceValue = reader.Get(resourceName);
}
else
{
resourceValue = "ConverterParameter missing in Binding tag"; //ERROR
}
return resourceValue;
}
catch
{
return "Localization Configuration Error";
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
public static string Get(object stringLibrary, string resourceName)
{
try
{
string resourceValue;
var reader = (IStringLibrary)stringLibrary;
if (!string.IsNullOrEmpty(resourceName))
{
resourceValue = reader.Get(resourceName);
}
else
{
resourceValue = "Invalid resourceName"; //ERROR
}
return resourceValue;
}
catch
{
return "Localization Configuration Error";
}
}
#endregion
}