【发布时间】:2010-12-07 10:54:16
【问题描述】:
问题是,DataGrid 中的空白行没有出现,因此用户无法添加数据。 代码如下:
System.Collections.ObjectModel.ObservableCollection<CoreVocabularyEntry> dataList = new System.Collections.ObjectModel.ObservableCollection<CoreVocabularyEntry>();
public VocabularyToolWindow()
{
InitializeComponent();
dataList.Add(new CoreVocabularyEntry { Foreign = "ja", Native = "ano" });
ListCollectionView view = new ListCollectionView(dataList);
WordsDataGrid.ItemsSource = dataList;
WordsDataGrid.CanUserAddRows = true;
MessageBox.Show(view.CanAddNew.ToString());
}
我不明白为什么 view.CanAddNew 等于 false。这看起来像是一个非常标准的场景,所以我可能缺少一些明显的东西。有人可以告诉我代码有什么问题吗? CoreVocabularyEntry 就是如下:
public struct CoreVocabularyEntry : IVocabularyEntry
{
#region IVocabularyEntry Members
public string Foreign
{
get;
set;
}
public string Native
{
get;
set;
}
#endregion
}
谢谢,J.K.
【问题讨论】: