I think your best bet is definitely a converter. Then your binding will look like this:
<TextBlock.Text> <MultiBinding Converter="{StaticResource StringFormatConverter }"> <Binding Path="Price"/> <Binding Path="DecimalPoints"/> </MultiBinding> </TextBlock.Text>
Then a quick converter (you can do it better, but this is a general idea).
public class StringFormatConverter : IMultiValueConverter { #region IMultiValueConverter Members public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double number = (double)values[0]; string format = "f" + ((int)values[1]).ToString(); return number.ToString(format); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion }
source share