title: wpf converters with different decimal number
body: <p>I have a lot of numbers to deal with from my UI. I want some of them to be no decimal places, some to be 2 decimals, and others to be however they are entered (3 or 4 decimal places).</p>
  
  <p>I have a converter named DoubleToStringConverter like this:</p>
  
  <pre><code>[ValueConversion(typeof(double), typeof(string))]
  public class DoubleToStringConverter : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
          return value == null ? null : ((double)value).ToString("#,0.##########");
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
          double retValue;
          if (double.TryParse(value as string, out retValue))
          {
              return retValue;
          }
          return DependencyProperty.UnsetValue;
      }
  }
  </code></pre>
  
  <p>Is there a way to write just one converter to achieve this? It seems there is no way to have a parameterized converter. The StringFormat in xaml seems to conver string to other type of data. It does not allow to display a substring from xaml.</p>
  
  <p>I can only think of making IntegerToStringConverter, Double2ToStringConverter, Double3ToStringConverter, etc. But I'd like to see whether there is a more efficient way.</p>