AddNew() not used to add new item via DataGrid

AddNew() not used to add new item via DataGrid

Old forum URL:

pegesaka posted on Monday, November 26, 2012

I am using CSLA 4.3.12 and .Net 4, developing a simple WPF app, without any view models etc. I have a BusinessListBase as the ItemsSource to a DataGrid. I have overridden AddNewCore()

    protected override MasterRoster AddNewCore() {
      var child = DataPortal.CreateChild<MasterRoster>();
      return child;

I have set AllowNew to true in its constructor.

But it appears that the only requirement to allow new items to be added via a DataGrid is to make the constructor of the list's children public. All the rest can be commented out, it has no effect.

I discovered this by trying to access the IObservableBindingList AddedNew event, which didnt fire. AddNewCore() was never visited.

This is not a show stopper as the child object is currently simple. I would like to use the blank row at the bottom of a DataGrid to create new child items, but if they become complex and require db initialisation then I will need to manually add new children, so I can use the factory methods, rather than use the blank grid row.

Am I missing something here?



RockfordLhotka replied on Tuesday, November 27, 2012

Sadly the WPF team decided not to support the add new concepts from Windows Forms...

This is a limitation of WPF (and SL) and the way they interact with data binding, and there's unfortunately nothing really to be done about it.

pegesaka replied on Wednesday, November 28, 2012

Normal 0 MicrosoftInternetExplorer4

Thanks Rocky.

Thats unfortunate. The reason I posted the question was because all the documentation on CSLA I have read suggests that it did support the AddNew functionality, so I'm glad to have it confirmed that I'm not missing something.

Is there any likelihood in the future that CSLA will support AddNew with WPF and DataGrids?

Can I just confirm then that for now the grid can be used to create new child instances as long as they dont require db access. If new children do require db access, DataGrid.CanUserAddRows needs to be disabled and new children need to be explicitly added with an 'Add' button etc.



Copyright (c) Marimer LLC