title: Handling WPF Editable combobox when entered text is not a part of datsource
body: <p>I have a Combobox in WPF, I have set Is Editable="true" which allows me enter any text in the combobox. I would like to restrict users from entering text outside datasource. </p>
  
  <p><strong>Xaml:</strong></p>
  
  <pre><code>&lt;ComboBox Name="service" Margin="0,0,0,4" 
      IsEditable="True"
      Grid.Column="1" 
      Grid.ColumnSpan="2" Grid.Row="4" 
      SelectedValuePath="Id" 
      DisplayMemberPath="Service" 
      SelectedValue="{Binding Controller.Service1}" 
      ItemsSource="{Binding}" /&gt;
  </code></pre>
  
  <p><strong>C#:</strong></p>
  
  <pre><code>System.Data.DataView vw = tableAdapterServices.GetData().DefaultView;
  service.ItemsSource = vw;
  service.SelectedIndex = 0;
  </code></pre>
  
  <p>I do not want to allow users to enter text which is not present in the datasource, or handle it if the user enters any other text.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Thanks for the solution @Vishal, LostFocus event is handling the issue, but it gave rise to another issue. I have a button which is used to submit the combobox value along with other textbox values to the server. I am setting default value in the combobox in lostfocus event. But I need to prevent the button click event if some value other that datasource value is added in combobox.</p>