如何在WPF中的DataGrid中添加空行 [英] How to add an empty row in datagrid in wpf

查看:463
本文介绍了如何在WPF中的DataGrid中添加空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据网格,该数据网格绑定到TwoWay路径中的列表.
我发现的网格的Enter键的默认行为是向下移动.

我使用以下代码使运动向右移动

I have a datagrid which is bound to a list in TwoWay path.
the default behavior of the enter key for the grid which i found is move down.

i used the following code to make the movement to the right

var element = e.OriginalSource as FrameworkElement;
if (e.Key == Key.Enter)
            {
                e.Handled = true;
                element.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            }



但是现在我的网格的问题是它没有为新项目添加空行.它没有做任何新的项目占位符.

1)有没有一种方法可以在wpf或
中的DataGrid中手动添加新的空行 2)我可以使用任何方法使网格能够添加新行或移动到最后一个可聚焦列之后的下一个新行吗?



But now the issue to my grid is that it does not add an empty row to for the new item. It is not making any new item place holder.

1) Is there a way to add manually a new empty row in DataGrid in wpf or
2) can i use any method to make my grid to be able to add a new row or move to the next new row after the last focusable column?
thank you in advance.

推荐答案

正如您所说,您已将Datagrid与List绑定在一起.然后将一项添加到列表中将自动在Datagrid中添加新行.尝试这种方式.
As you said, you have bound the Datagrid with List. Then adding one item to List will automatically add new row in Datagrid. Try this way.


这篇关于如何在WPF中的DataGrid中添加空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆