title: WPF prevent combobox selection change under condition
body: <p>I have a ComboBox who's selected index is binded into an integer. What I am trying to do is to prevent the combobox selection from changing if a certain condition is not met. Here's what I have so far</p>
  <p>In xaml:</p>
  <pre><code>&lt;ComboBox SelectedIndex=&quot;{Binding CurrentMinCondition,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}&quot;&gt;
      &lt;ComboBoxItem&gt;NA&lt;/ComboBoxItem&gt;
      &lt;ComboBoxItem&gt;LT&lt;/ComboBoxItem&gt;
      &lt;ComboBoxItem&gt;GT&lt;/ComboBoxItem&gt;
  &lt;/ComboBox&gt;
  </code></pre>
  <p>In cs:</p>
  <pre><code>private int _currentMinCondition = 0;
  public int CurrentMinCondition
  {
      get { return _currentMinCondition; }
      set
      {
          if (/*Condition is met*/){
              _currentMinCondition = value;
              OnPropertyChanged(&quot;CurrentMinCondition&quot;);
          }
          else
          {
              MessageBox.Show(&quot;Error&quot;);
              _currentMinCondition = 0;
              OnPropertyChanged(&quot;CurrentMinCondition&quot;);
          }
      }
  }
  </code></pre>
  <p>Now I thought this would work but what happens is that when I change my selection from the combo box and the condition is not met, my <code>MessageBox</code> shows an error but the graphical combobox changes its selection. How can I prevent this from happening?</p>