It's not "wrong" if you are using the valueconverter for what it is designed to do. Personally i use them to translate enum values to friendly strings, but rather than hard coding the string in to the value converter the VC uses the enum value to source the string from a resource file.
In the specific case you mention, i would do things a little differently to cut down on the amount of VC's you have - you can do it with just one. What you are doing is substituting/inserting the value straight into a known string. What you can do is start using the ConverterParameter
that is available to you, and use it to pass the ID of a string in your resource file, the value that is passed in to the VC can then be inserted into the string specified by the VCs ConverterParameter
. Here is a quick pseudo code example:
public class MyConverter : IValueConverter
{
public MyConverter()
{
_rm = new ResourceManager("[my_assembly_name].Resources.strings", Assembly.GetExecutingAssembly());
}
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (parameter is string && !string.IsNullOrEmpty((string)parameter))
{
string z = _rm.GetString((string)parameter);
if (z != null)
{
return string.Format(z, value);
}
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
ResourceManager _rm;
}
And you would use this converter like this:
<TextBlock Text={Binding someNumericValue, Converter={StaticResource MyConverter}, ConverterParameter=[key_to_resource_string]} />
Also have a look at WPF4 - IIRC it has an ability to be able to specify a format string as part of the binding expression, this may help you as well.