title: XAML: Can I overload binding resolution?
body: <h1>Y: The Question</h1>
  
  <p>A binding is "merely" a set of name-string pairs which are interpreted at runtime. When this produces unexpected results, can the binding resolution be intercepted? This could reveal issues such as timing problems (improper initialization order, race conditions) and typos, or eliminate them so the debugging focus can be moved.</p>
  
  <p>I'm hoping for a way to intercept the call to <code>Binding.ProvideValue</code>, or similar, but with all the relevant information (<code>Path</code>, <code>DataItem</code>, etc.) available. I want to know how the <code>Binding</code> class understands my instructions, and <strong>when</strong>.</p>
  
  <p>I tried <a href="https://stackoverflow.com/a/3155899/639739">using an <code>IValueConverter</code></a>, but it's not called before the error (below) occurs.</p>
  
  <p>I tried writing a <code>MarkupExtension</code>, with a private <code>Binding</code> instance, but it didn't help me out by retrieving the relevant information for free. Specifically, it didn't determine the appropriate <code>DataItem</code> inherited via <code>DataContext</code>. <em>(I'm guessing it acquires the information through <code>internal</code> communications with the containing XAML element, since <code>static</code> code wouldn't be prejudiced against me.)</em></p>
  
  <h1>X: The Problem</h1>
  
  <p>I'm working with this binding, which happens to be on an <a href="http://www.actiprosoftware.com/" rel="nofollow noreferrer">actipro</a> property grid item (and several otherwise identical bindings work just fine):</p>
  
  <p><em>(edited because I initially copied the wrong binding)</em></p>
  
  <pre><code> Value="{Binding VMLeftPLaneOneHoleHoleOneSlugCylinderLen,
                   Mode=OneWay,
                   StringFormat=F3}"
  </code></pre>
  
  <p>I can't shake the following runtime error. The property <strong>exists</strong> on the mentioned class, and no <strong>spelling</strong> error is involved (reasonable guess due to the absurdly long name). It is available <strong>public</strong>ly (other properties weren't, this is my last one). The property only provides a getter, hence <code>Mode=OneWay</code>.</p>
  
  <pre><code>System.Windows.Data Error: 40 : BindingExpression path error: 'VMLeftPLaneOneHoleHoleOneSlugCylinderLen' property not found on 'object' ''LegacyViewModel' (HashCode=3273904)'. BindingExpression:Path=VMLeftPLaneOneHoleHoleOneSlugCylinderLen; DataItem='LegacyViewModel' (HashCode=3273904); target element is 'PropertyGridPropertyItem' (Name=''); target property is 'Value' (type 'Object')
  </code></pre>
  
  <p>I've been staring at the code, and I'm in that mood where I'm sure I've checked everything and totally implausible explanations are popping into my head - like the XAML interpreter having a different <code>LegacyViewModel</code> class, one which lacks this specific property. And after typing that I went ahead and hit Clean+Rebuild just to make sure.</p>
  
  <p>I don't have a minimal test case, mostly because this project is gargantuan and unmaintainable in multiple ways. But I'm not asking for a solution to the actual problem, only a <strong>technique</strong> to help me solve it.</p>
  
  <p>Did I make a blatantly obvious mistake? Is there something I haven't checked? <strong>What can I do to measure this fairly deep part of the XAML system?</strong></p>