DataGrid user add rows for XML content?

Sep 10, 2008 at 7:34 PM
I enabled "CanUserAddRows" to my datagrid which is bound to XML content, but it didn't change anything.  What's the interface for using this properly?  Am I missing something?
Sep 11, 2008 at 2:03 AM
I am having the same issue - the bindings work but I can't get the "CanUserAddRows" to work either. When I add "Mode=TwoWay" to the binding I see this error:

A TwoWay or OneWayToSource binding cannot work on the read-only property 'Item' of type 'MS.Internal.Data.XDeferredAxisSource'.

I was able to wrap my grid data in an ObservableCollection<T> and I could get the 'delete' to work (CanUserDeleteRows), but did not get the empty 'new' row and this makes a copy of the collection and I lose the syncronization between the ui and the backing xml data.

Does anyone know what the specific requirements are on the underlying collection to make "CanUserAddRows" work?
Coordinator
Sep 11, 2008 at 2:50 PM
When using an XmlDataProvider as the ItemsSource you get a ListCollectionView but the collection is a fixed size.  Because of that CanUserAddRows is coerced to false even if you try to set it to true. 

See the comments on this post, http://blogs.msdn.com/vinsibal/archive/2008/05/27/using-ieditablecollectionview-with-dynamically-generated-gridviewcolumns.aspx, for the requirements for CanUserAddRows to work.
Sep 11, 2008 at 4:19 PM
Would there be a way I can fake this?  Bind an empty row to the end of the data grid, then create the element I need when the user goes to edit the empty cell?
Coordinator
Sep 11, 2008 at 8:54 PM
That isn't really how IEditableCollectionView works.  If you don't have bound data then you can do this by calling DataGrid.Items.Add but I'm guess that you don't want to do that as the XmlDataProvider is a requirement.