title: AutoCompleteBox with TextChanged event not selecting properly
body: <p>Hi I'm using an <strong>AutoCompleteBox</strong> like this</p>
  
  <pre><code>&lt;!-- XAML Code --&gt;
  &lt;sdk:AutoCompleteBox Grid.Row="2"
           FilterMode="None"
           ItemsSource="{Binding Customers}"
           SelectedItem="{Binding Path=SelectedCustomer, Mode=TwoWay}"
           Text="{Binding CustomerSearchString, Mode=TwoWay}"
           ValueMemberBinding="{Binding Path=FullName}"
           ValueMemberPath="FullName"
           TextChanged="{ext:Invoke MethodName=Search, Source={Binding}}"/&gt;
  </code></pre>
  
  <p>C# part:</p>
  
  <pre><code>// Search Method in the viewmodel
  public void Search()
  {
      var customerOperation = _context.Load(_context.GetCustomerByNameQuery(CustomerSearchString));
      customerOperation.Completed += (s, e) =&gt; Customers = new List&lt;Customer&gt;(customerOperation.Entities);
  }
  </code></pre>
  
  <p>In my app to quick-search for customers for an fast and uncomplicated method to search. I get it to display everything correctly in the dropdown, and when I select with the mouse it works perfectly.</p>
  
  <p>But when I press <em>ArrowDown</em>, you see the text come up for a split-second but then it reverts and puts the cursor back in the textbox instead of selecting the first entry down. I tried using the TextInput event, but that one won't fire.</p>
  
  <p>How can I avoid this behaviour?</p>
  
  <p><strong>SOLUTION:</strong></p>
  
  <p>The problem was, that the TextChanged event got fired when the user selected an entry, creating some sort of race condition like behaviour where the Text got reset. <em>The solution was to use the <strong>KeyUp</strong> event (don't use KeyDown, because the Text property won't be updated yet). This event doesn't get triggered when the user selects something, solving the problem.</em></p>
  
  <p><strong>Final code (ViewModel unchanged):</strong></p>
  
  <pre><code>&lt;!-- XAML Code --&gt;
  &lt;sdk:AutoCompleteBox Grid.Row="2"
           FilterMode="None"
           ItemsSource="{Binding Customers}"
           SelectedItem="{Binding Path=SelectedCustomer, Mode=TwoWay}"
           Text="{Binding CustomerSearchString, Mode=TwoWay}"
           ValueMemberBinding="{Binding Path=FullName}"
           ValueMemberPath="FullName"
           KeyUp="{ext:Invoke MethodName=Search, Source={Binding}}"/&gt;
  </code></pre>
  
  <p>Thanks everyone!</p>