能够参考这个代码 http://www.cnblogs.com/Leaco/p/3164394.htmlhtml
当你发现没用的时候 能够改这句代码 var hwnd = ((HwndSource)PresentationSource.FromVisual(this).Handle;this
改为var hwnd = ((HwndSource)PresentationSource.FromVisual(this.Child).Handle;spa
textbox可能失去光标,这个时候须要在后面增长TextBox.Focus()事件;htm
可能还须要设置TextBox.SelectStart =TextBox.Length 来定位光标到最后面。blog