如何在绑定到ObservableCollection< T>?时删除DataGrid的空白行 [英] How to remove DataGrid's blank row when binding to a ObservableCollection<T>?
本文介绍了如何在绑定到ObservableCollection< T>?时删除DataGrid的空白行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里得到坚果:
ObservableCollection< Employee> list = new ObservableCollection< Employee>();
dgEmployees.ItemsSource = list;
当您调试列表变量时,它为空(list.Count = 0),但是我绑定它到一个DataGrid(WPFToolkit),它显示一个空行。
在立即窗口中,对于dgEmployees.Items它显示:
dgEmployees.Items [0]
{NewItemPlaceholder}
和
dgEmployees.Items [0] .GetType()
/ pre>
{Name = NamedObjectFullName =MS.Internal.NamedObject}
[System.RuntimeType]:{Name =NamedObjectFullName =MS.Internal.NamedObject}
在将此Datagrid放入TabControl后,似乎发生了,但我不确定与它有关。
有谁知道如何删除这个空白行?
解决方案我有它在Datagrid XAML上的
,放置属性:
IsReadOnly = 真
I'm getting nuts here with this:
ObservableCollection<Employee> list = new ObservableCollection<Employee>(); dgEmployees.ItemsSource = list;
When you debug the list variable, it's empty (list.Count =0), but then I bind it to a DataGrid (WPFToolkit), it shows me a blank row.
In immediate window, for dgEmployees.Items it's showing:
dgEmployees.Items[0] {NewItemPlaceholder}
and
dgEmployees.Items[0].GetType() {Name = "NamedObject" FullName = "MS.Internal.NamedObject"} [System.RuntimeType]: {Name = "NamedObject" FullName = "MS.Internal.NamedObject"}
It seems to happen after I've put this Datagrid into a TabControl, but I'm not sure it has something to do with it.
Does anyone know how to remove this blank row?
解决方案I've got it
on Datagrid XAML, put the attribute:
IsReadOnly="True"
这篇关于如何在绑定到ObservableCollection< T>?时删除DataGrid的空白行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文