【问题标题】:WPF DataGrid - How to move keyboard focus to newly added row after tab pressWPF DataGrid - 如何在标签按下后将键盘焦点移动到新添加的行
【发布时间】:2011-02-08 08:34:06
【问题描述】:

如果我们在最后一行的最后一列上按 Tab,WPF DataGrid 会添加一个新行。但添加新行后,焦点将移至网格的顶行。我们如何确保焦点移动到新行的第一列?

【问题讨论】:

    标签: wpftoolkit wpfdatagrid


    【解决方案1】:

    你可以试试

    this.SelectRowCell(this.Items.Count - 1, 0);
    

    但我不确定这是否也会成为焦点。如果没有,请尝试以下操作:

    DataGridCell cell = this.GetCell(this.Items.Count - 1, 0);
    
    if (cell != null)
    {
        cell.Focus();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-11
      • 2011-01-10
      • 2016-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-10
      • 1970-01-01
      相关资源
      最近更新 更多