title: Can I use IFormatProvider with a WPF Binding to a custom type?
body: <p>I have a custom type (<code>SINumber</code>, which represents an SI number with appropriate units and prefix). I can bind to a <code>SINumber</code> fine and override <code>SINumber.ToString()</code>, but what is displayed is the result of calling SINumber.ToString().</p>
  
  <p>For example, SIMeasurement is of type <code>SINumber</code> with an SI value of 3099999.9046325684 Ω. Using the following Binding, I get an output of 3.09999990463257 MΩ. </p>
  
  <pre><code>&lt;TextBlock Text="{Binding SINMeasurement}"&gt;&lt;/TextBlock&gt;
  </code></pre>
  
  <p>The units (Ω) and prefix (M = mega) conversation are correct, the problem is with the number of numerals displayed. I want to be able to use a custom formatter (implementing <code>IFormatProvider</code>  <code>ICustomFormatter</code>?) to interpret the <code>StringFormat</code> from the Binding, and incorporate my SI-logic (changing prefix) to display <strong>3.10 MΩ</strong>. Below is an example of the Binding I would like to use, where the precision is customizable (0.00 in this case), and the location of the units are determined by the 'U'.</p>
  
  <pre><code>&lt;TextBlock Text="{Binding SINMeasurement, StringFormat='{}{0:0.00 U}'}"&gt;&lt;/TextBlock&gt;
  </code></pre>
  
  <p>Any thoughts? I don't want to use the hard-coded <code>SINumber.ToString()</code>, as the desired precision will vary in different locations within the application.</p>
  
  <p>Thanks in advance.</p>