/// <summary>
 /// Like FocusNextCompletion but focuses the previous completion.
 /// </summary>
 /// <param name="stackPanel"></param>
 public static void FocusPreviousCompletion(StackPanel stackPanel, TextBox textBox)
 {
     for (int i = 0; i < stackPanel.Children.Count; i++)
     {
         TextBlock child = (stackPanel.Children[i] as TextBlock);
         if (child.IsFocused && stackPanel.Children.Count > 1 && i - 1 > -1)
         {
             AutoCompleteResult toFocus      = (stackPanel.Children[i] as AutoCompleteResult);
             AutoCompleteResult takeTextFrom = (stackPanel.Children[i - 1] as AutoCompleteResult);
             toFocus.Focus();
             textBox.Text = (takeTextFrom.Text);
             return;
         }
     }
 }
 /// <summary>
 /// Focuses the completion below the current completion, or the first completion if none is selected.
 /// </summary>
 /// <param name="stackPanel">The StackPanel holding the autocompletions</param>
 /// <param name="textBox">The destination text box that the autocomplete will complete.</param>
 public static void FocusNextCompletion(StackPanel stackPanel, TextBox textBox)
 {
     for (int i = 0; i < stackPanel.Children.Count; i++)
     {
         AutoCompleteResult child = (stackPanel.Children[i] as AutoCompleteResult);
         if (child.IsFocused && stackPanel.Children.Count > 1 && i + 1 < stackPanel.Children.Count)
         {
             textBox.Text = (stackPanel.Children[i + 1] as AutoCompleteResult).Text;
             return;
         }
     }
     if (stackPanel.Children.Count > 0)
     {
         AutoCompleteResult destination = stackPanel.Children[0] as AutoCompleteResult;
         destination.Focus();
         textBox.Text = destination.Text;
     }
 }