如何隐藏或删除新的占位符行数据网格? [英] How hide or remove a new place holder row of data grid?

查看:76
本文介绍了如何隐藏或删除新的占位符行数据网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我以编程方式向数据网格添加新行时,还会在我的WPF数据网格底部添加一个新的占位符。

我设置CanUserAddRows = True in xaml代码。

如何隐藏或删除WPF数据网格的新占位符行?

谢谢。

对不起英文错误。

Hi,
when i add new row to data grid programmatically also add a new place holder in bottom of my WPF data grid.
I set CanUserAddRows=True in xaml code.
How i can hide or remove new place holder row of WPF data grid?
Thanks.
Sorry for bad English.

推荐答案





这取决于你如何设置 Items DataGrid 的集合。



如果基础项源实现 IEditableCollectionView

您可以在将 CanUserAddRows 设置为true后尝试此(在代码中):



Hi,

it depends how you set the Items collection of the DataGrid.

If the underlying items source implements IEditableCollectionView
you could try this (in code) after setting CanUserAddRows to true:

var editableCollection = (IEditableCollectionView)dataGrid.Items;

if (editableCollection != null)
{
  editableCollection.NewItemPlaceholderPosition = NewItemPlaceholderPosition.None;
}





这样可以防止数据网格显示新的项目行。



问候,



Thomas。



This should prevent the datagrid to display the new item row.

Regards,

Thomas.


这篇关于如何隐藏或删除新的占位符行数据网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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