Where is the extra "add" row?

Feb 18, 2009 at 2:35 PM
I am using the datagrid with Delphi Prism and Eco 5.  I can bind the Eco object list to the datagrid and see the data and update the database through the grid.  However, there is no "extra" row at the end of the grid to allow adding a new object.  I see this extra row with other examples I have downloaded from the web that use other dataproviders.  Is there something special I have to do to make the "extra" row show up?  What is the datagrid looking for to determine to add that extra row?

Also, when I add a new object through a button press, the grid doesn't show the new object in the list.  What do I have to do to get the grid to show the new data?
Feb 18, 2009 at 5:26 PM
Take a look at this post on editing, http://blogs.msdn.com/vinsibal/archive/2008/10/01/overview-of-the-editing-features-in-the-wpf-datagrid.aspx.  In particular, take a look at the info on CanAddNew. 
Feb 18, 2009 at 8:39 PM

   My problem is that the extra row in the datagrid where a new row could be added isn't there.  Without it being there, I don't see how the InitializingNewItem event would get triggered.   I don't see anything (in your otherwise very interesing) write-ups that would help me.

   Got anything else :)
Feb 24, 2009 at 1:39 PM
In your particular DataGrid, does CanUserAddRows evaluate to false?  Also, what does this, (CollectionViewSource.GetDefaultView(dataGrid.ItemsSource) as IEditableCollectionView).CanAddNew, evaluate to?
Feb 24, 2009 at 2:06 PM
I JUST got this to apparently all work!!!  (and it only took about a week)

I was able to make an ObservableCollection passing the Eco GetAsIList as an argument to the constructor and bind the datagrid ItemsSource to that dynamically.

Then on my Person class, I needed to have a constructor with no parameters.  The default generated Eco Person class always has 1 parameter, the EcoSpace that will contain the Person and be responsible for persisting it to a database of some sort.  I was able to add a constructor with no parameter to the partial class and, in that, call the constructor with one parameter.  I had to make a class variable for Person that contained the EcoSpace to use so that the constructor could put the Person in that EcoSpace when the DataGrid tried to create it.

Having the "empty" constructor was the key that finally turned on the "extra row".

I also made the Person implement IEditableObject and INotifyPropertyChanged, but I'm not sure at the moment if the INotifyPropertyChanged was really necessary.

But I'm making some progress and REALLY glad the DataGrid is available AND that it works with Eco.