'EditItem' is not allowed for this view. WPF .NET 4 / EF 4.1 - Master - Detail

后端 未结 1 1491
陌清茗
陌清茗 2020-12-21 07:02

Ok, in order to try to find an answer for this question I have made an even simpler project, using the AdventureWorks database.

I created a Model from the Vendor and

相关标签:
1条回答
  • 2020-12-21 07:49

    If the PurchaseOrderHeaders collection property in your Vendor class is of type ICollection<T> then this could be source of your problem. To get a datagrid which allows editing the source collection must be of type IList<T> or any type which implements IList<T> like List<T> or ObservableCollection<T>. You will probably need to change the collection type of PurchaseOrderHeaders in your model class accordingly.

    More detailed explanation is here: Getting Readonly Databind using EF POCO Objects

    Edit

    According to @Allon Guralnek's comment below it is necessary to implement the non-generic IList interface to get an editable DataGrid. This is the case for ObservableCollection<T> and List<T>. Other implementations which only implement the generic IList<T> but not the non-generic IList won't make the DataGrid editable.

    0 讨论(0)
提交回复
热议问题