Hello,
I display a list of categories of books and for each, I display as a sub collection, all the book in it.
I would like to be abble to add a book to a category but there is no "add" row for the childs fieldLayout...How can I perform this ?
There are couple of things that you need to ensure in order to have an AddNewRow in a fieldlayout
1. Set the AllowAddNewRecord property of the FieldLayout's Settings
2. The underlying collection should implement IBindingList interface
3. The underlying class (if you bind to one) should have a parameterless constructor
Thanks for the reply,
:-(
Helo,
I have the same problem. Your example works fine, but it doesn't work with entity framework. If you bind collections from EF, you cannot add rows to top level of hierarchy (ListCollectionView helps in this case) and to newly added rows in sub levels of hierarchy. Do you have any best practice or guidelines, how to use xamDatagrid binding with entity framework hierarchies ?
John Lynx
Senior Software DeveloperToyota Motor
I was just wondering if you have tried the attached sample and if that is what you were looking for?
You can find a sample project attached. You could probably see what you are missing and make it work in your setup.
Even with a ListCollectionView it does not work...
To be sure : I am talking of adding an item to a sub collection( like adding a book in the "sci fi category ):
|---Sci-Fi category | |---> book 1 | |---> book 2 | |---> book 3 |--- adventure category |---> book 1 |---> book 2 |---> book 3
ObservableCollection does not implement IBindingList. You can try with BindingList<T> or wrapping the observablecollection in a collection view, like this:
ListCollectionView view = new ListCollectionView(myObservableCollection);
xamDataGrid.DataSource = view;