title: Undoing a SourceUpdated binding operation on a ComboBox
body: <p>My <code>ComboBox</code>:</p>
  
  <pre><code>&lt;ComboBox
      SourceUpdated="MyComboBox_SourceUpdated"
      ItemsSource="{Binding ...}"
      SelectedValue="{Binding Path=SelectedValueMember, NotifyOnSourceUpdated=True}"
      SelectedValuePath="..."
      DisplayMemberPath="..."
  /&gt;
  </code></pre>
  
  <p>And my <code>SourceUpdated</code> handler:</p>
  
  <pre><code>private void MyComboBox_SourceUpdated(object sender, DataTransferEventArgs args) {
      if (/* user answers no to an 'are you sure?' prompt */) {
          // TODO: revert ComboBox back to original value
      }
  }
  </code></pre>
  
  <p>I'm having difficult reverting the ComboBox back to its original value (in the "TODO" comment of my code above).</p>
  
  <p>The first and most obvious thing I tried was to simply change back the value of the SelectedValueMember of the DataContext, assuming the binding would update the ComboBox:</p>
  
  <pre><code>MyDataContext.SelectedValueMember = original_value;
  </code></pre>
  
  <p>When I do this, in the debugger I can see that it is indeed updating the SelectedValueMember value, but the ComboBox does not change back - it holds onto the new value.</p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p><strong>AngelWPF's</strong> answer below works and is probably the neatest and clearest way.</p>
  
  <p>I did however, find a non-obvious solution:</p>
  
  <pre><code>private void MyComboBox_SourceUpdated(object sender, DataTransferEventArgs args) {
      if (/* user answers no to an 'are you sure?' prompt */) {
          Dispatcher.BeginInvoke(new Action(() =&gt; {
              MyDataContext.SelectedValueMember = original_value;
          }));
      }
  }
  </code></pre>
  
  <p>Just by putting the operation on a second UI thread by means of <code>BeginInvoke</code>, it works! I could be wrong, but my hunch is that to avoid binding update loops, the actions directly in Source/Target Updated handlers are not reacted to by bindings.</p>