title: Different TextBox formatting in edit mode
body: <p>In our WPF project, we are using a TextBox to let the user enter some length measures. This measures may be in millimeters, centimeters, inches, etc (depending on the user configuration).</p>
  
  <p>We need to show the numbers on the TextBox along with the current measurement unit, like:
  "120 mm"
  "16 cm"
  "1' 2 3/4"
  and so on.</p>
  
  <p>I am using ValueConverter to both perform the unit converting and to add the extra formatting. The UpdateSourceTrigger is default, so the binding applies when the user leaves the control.</p>
  
  <p>The challenge here is that while editing the value, these "mm" or "cm" are not shown. So the previous examples in edit mode would be:
  "120"
  "16"
  "1 2 3/4"</p>
  
  <p>How can I make that happen?</p>
  
  <p>Here is the Converter code for some cenários:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Converts and formats the value (in milimeters) to the required unit/format
  /// &lt;/summary&gt;
  public class LengthConverter : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
          LengthUnit unit = MainWindow.CurrentLengthUnit;
  
          switch (unit.Id)
          {
              case 1: //Milimeters
                  return value + " mm";
              case 2: //Centimeters
                  return (double)value / 10.0 + " cm";
              default:
                  throw new InvalidOperationException("Unknown length unit.");
  
          }
  
      }
  
      public object ConvertBack(object value, Type targetType,
             object parameter, CultureInfo culture)
      {
          string rawValue = value as string;
  
          LengthUnit unit = MainWindow.CurrentLengthUnit;
  
          switch (unit.Id)
          {
              case 1: //Milimeters
                  return rawValue.Replace("mm", "").Trim();
              case 2: //Centimeters
                  return Double.Parse(rawValue.Replace("cm", "").Trim()) * 10.0;
              default:
                  throw new InvalidOperationException("Unknown length unit.");
          }
      }
  }
  </code></pre>