English 中文(简体)
WPF DataGrid -row for new entry notprofile
原标题:WPF DataGrid - row for new entry not visible
  • 时间:2009-10-16 17:34:19
  •  标签:

The problem is, that the blank row in the DataGrid isn t appearing, ergo user can not add data. Here is the code:

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());
    }

我可以说明为什么有观点。 CanAdd New等于假。 这看起来像一种极好的假想,因此可能有一些迷惑。 谁能告诉我该法典有什么错误? CoreVocabul 加入:

public struct CoreVocabularyEntry : IVocabularyEntry
{
    #region IVocabularyEntry Members

    public string Foreign
    {
        get;
        set;
    }

    public string Native
    {
        get;
        set;
    }

    #endregion
}

Thx, J.K.

最佳回答

Move WordsDataGrid.CanUserAddRows = real; above the statement where You set the DataGrid s ProjectSource.

http://www.un.org。

详情请洽http://msdn.microsoft.com/en-us/library/system.componentmodel.ieditableobject.aspx” rel=“nofollow noreferer” 如果使用数据集的编辑特征,你需要这样做。

问题回答

This may be more simple than above. I had this problem when I did NOT have a default constructor and therefore the datagrid did not know how to add the new row. My only constructor involved a bunch of information to be supplied. Go to the object of that the List<> is made from and add a constructor like: public MyClass(){} Hope this helps!





相关问题
热门标签