Changing the focus from the input event handler (i.e., clicking on a virtual key) will fail because the mouse event (or key) will return focus to the original element. To make it work, you need to send the focus command later using the object Dispatcher.
Example:
Dispatcher.Invoke(new Action(() =>
{
textBox1.Focus();
textBox1.SelectionStart = textBox1.Text.Length;
// or textBox1.Select(textBox1.Text.Length,0);
}), System.Windows.Threading.DispatcherPriority.Background);
source
share