title: WPF Editable ComboBox validation
body: <p>What I want to accomplish is to be able to validate for new category typed into the editable combobox or for one to be selected from existing combobox'es list of categories.</p>
  
  <p>The validation works for selectedItem only, not for new text entered into Text. As soon as I add the <code>ValidateOnDataErrors="True"</code> to ComboBox'es Text property, events from entering new text are not firing. Category is a simple object with Id and Name.</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;ControlTemplate x:Key="ValidationErrorTamplate"&gt;
          &lt;Border BorderBrush="DodgerBlue" BorderThickness="0.75"&gt;
              &lt;AdornedElementPlaceholder /&gt;
          &lt;/Border&gt;
      &lt;/ControlTemplate&gt;
      &lt;Style x:Key="ElementInError" TargetType="{x:Type FrameworkElement}"&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="Validation.HasError" Value="True"&gt;
                  &lt;Setter Property="ToolTip" Value="{Binding (Validation.Errors)[0].ErrorContent, RelativeSource={x:Static RelativeSource.Self}}" /&gt;
              &lt;/Trigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  &lt;/Window.Resources&gt;
  
  &lt;ComboBox Name="CbCategory"
            DisplayMemberPath="Name"
            IsEditable="True"
            ItemsSource="{Binding Categories}"
            SelectedItem="{Binding SelectedCategory,
                                   UpdateSourceTrigger=PropertyChanged,
                                   ValidatesOnDataErrors=True}"
            Style="{StaticResource ElementInError}"
            Text="{Binding NewCategory.Name,
                           UpdateSourceTrigger=PropertyChanged,
                           ValidatesOnDataErrors=True}"
            Validation.ErrorTemplate="{StaticResource ValidationErrorTamplate}" /&gt;
  </code></pre>
  
  <p>ViewModel: (<code>: IDataErrorInfo</code>)</p>
  
  <pre><code>    private Category _newCategory;
      private Category _selectedCategory;
  
      public ExpenseCategory SelectedCategory
      {
         get { return _selectedCategory; }
         set
             {
                if (Equals(_selectedCategory, value)) return;
                _selectedCategory = value;
                SendPropertyChanged("SelectedCategory");
              }
       }
       public ExpenseCategory NewExpenseCategory
       {
          get { return _newExpenseCategory ?? (_newExpenseCategory = new ExpenseCategory()); }
              set
              {
                  if (Equals(_newExpenseCategory, value)) return;
                  _newExpenseCategory = value;
                  SendPropertyChanged("NewExpenseCategory");
              }
          }
  
  public string this[string propertyName]
          {
              get
              {
                  switch (propertyName)
                  {
                      case "SelectedExpenseCategory":
                      case "NewExpenseCategory":
                          {
                              if ((SelectedCategory == null) || (NewCategory == null)
                              {
                                  return "Category must be selected or entered";
                              }
                          }
                          break;
                  }
                  return string.Empty;
              }
  </code></pre>