将控件聚焦在Tabcontrol中

时间:2009-05-21 11:06:53

标签: wpf focus tabcontrol tabitem

在tabcontrol中选择tabitem时如何关注控件?

2 个答案:

答案 0 :(得分:1)

您应该捕获TabControl的Selection更改事件,并在其中集中您需要的控件。就像

一样
private void TabControl1_SelectionChanged(object sender, EventArgs e)
{
    control1.Focus();
}

答案 1 :(得分:1)

我不确定我完全理解您的要求,但您可能想捕获TabControl的SelectionChanged事件:


public Window1()
{
  InitializeComponent();

  TabControl1.SelectionChanged += TabControl1_SelectionChanged;
}

private void TabControl1_SelectionChanged(object sender, EventArgs e)
{
  TabItem item = (TabItem)TabControl1.SelectedItem;
  // Find the first control in the TabItem content and focus it?
}