在 wpf datagrid 中如何将空白行放在最上面? [英] in wpf datagrid how to get the blank row on top?

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

问题描述

在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天全站免登陆