在wpf datagrid中如何获取顶部的空白行? [英] in wpf datagrid how to get the blank row on top?

查看:210
本文介绍了在wpf datagrid中如何获取顶部的空白行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取顶部的空白行?即当用户想添加新行时,它总是在底部。但是我希望它在上面...我可以在XAML中执行此操作吗?

in wpf datagrid how to get the blank row on top? ie when user wants to add new row, it always comes at the bottom. But I want it to be on top ... can i do this in XAML ?

推荐答案

NewItemPlaceholderPosition.AtBeginning ?我没有代码示例,但似乎是你正在描述的。你可以随时做Johan的建议,并以编程方式移动或排序网格中的项目。

What about NewItemPlaceholderPosition.AtBeginning? I don't have a code example but that seems to be what you're describing. You could always do what Johan is suggesting and Move or Sort the items in the grid programmatically.

Ray Burns添加的代码示例:

Code example added by Ray Burns:

var view = CollectionView.GetDefaultCollectionView(EmployeeList)
             as IEditableCollectionView;
if(view!=null)
  view.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;

请注意,这需要.NET Framework 3.5或更高版本。

Note that this requires NET Framework 3.5 or above.

这篇关于在wpf datagrid中如何获取顶部的空白行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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