title: Accessing Binding from Type Converter?
body: <p>I've spent a fair bit of time trying a number of different ways to solve an issue I'm having, to no avail, so I'm hoping someone here can help.</p>
  
  <p>I have a Text Box element with Two-Way binding, which utilises a Type Converter to convert the value from a string to a custom Data type, say, <code>MyCustomType</code>. This is working fine, however due to a change in my project's requirements, I now need to perform extra processing prior to the conversion taking place.</p>
  
  <p>In order to perform this extra processing, however, I need to be able to access the "source" text box, or the binding context. Neither of which I have been able to access.</p>
  
  <p>Is there any way to access the source text box, from a Type Converter's <code>ConvertFrom()</code> method?</p>
  
  <p>I have tried to use the <code>ITypeDescriptorContext</code> parameter passed (by WPF) to the <code>ConvertFrom()</code> method, however most of the properties therein are null.</p>
  
  <p>i.e.</p>
  
  <pre><code>public class MyCustomTypeConverter : TypeConverter
  {
     ...
     public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
     {
        // Context is
        return new MyCustomType(value);
     }
     ...
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/QMsoD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QMsoD.png" alt="The context within ConvertFrom()"></a></p>
  
  <p><a href="https://i.stack.imgur.com/G4Puv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G4Puv.png" alt="Context - additional properties"></a></p>
  
  <p>I have also tried using a <code>MultiValueConverter</code>, and avoiding the Type converter entirely, however this led to a <strong>LOT</strong> of extra code, and didn't really help. I would prefer to avoid going down this route, as a Type Converter is much more elegant.</p>
  
  <p>Any advice/assistance would be greatly appreciated! :)</p>