开发者

WPF - TabControl Problem

I have a TabControl with three Tab Items. When the user clicks on the second TabItem, I want to take him/her back to the first TabItem and set a certain TextBox to have the keyboard focus, if a certain circumstance is met. I'm having a heck of a time making this happen. I can easily set the current TabItem to the first one, but no matter what I try, I cannot get the keyboard focus to the TextBox I want. I've tried calling the Focus method on the TextBox and I've tried using the Keyboard.Focus() method. Nothing seems t开发者_如何学Pythono work.


Use the follwing code:

// Select here your tab
// ...
Dispatcher.BeginInvoke(new Action(delegate {       
    yourTextBox.Focus();        
 }), System.Windows.Threading.DispatcherPriority.ContextIdle, null);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜