我的解決辦法:
private void TabControl_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
Dispatcher.BeginInvoke(() =>
{
FormsControl.Focus();
System.Windows.Input.Keyboard.Focus(ControlHost);
Dispatcher.BeginInvoke(() => FormsControl.Focus());
});
}
public static class DispatcherExtensions
{
/// <summary>
/// Executes the specified delegate asynchronously on the thread the System.Windows.Threading.Dispatcher is associated with.
/// </summary>
/// <param name="dispatcher">System.Windows.Threading.Dispatcher</param>
/// <param name="a">A delegate to a method that takes no arguments and does not return a value, which is pushed onto the System.Windows.Threading.Dispatcher event queue.</param>
/// <returns>An object, which is returned immediately after Overload:System.Windows.Threading.Dispatcher.BeginInvoke is called, that represents the operation that has been posted to the System.Windows.Threading.Dispatcher queue.</returns>
public static DispatcherOperation BeginInvoke(this Dispatcher dispatcher, Action a)
{
return dispatcher.BeginInvoke(a, null);
}
}