views:

28

answers:

0

Adding objects with the IEditableCollectionView addNew() method is pretty decent. However I'm not sure how well it works with my generic code I have.

I have a ObservableCollection of my base class. Depending on what the user wants to see it can be filled with DerivedA or DerivedB ( or mutliple other derived type classes ). It never has a more then 1 type. I have the following questions about this with number 1 being the main question.

1) What type of object is added when the addNew() method is called. I'm guessing base but not sure. What if Base is abstract? Is there anyway I can ensure it adds a specific type or is it implemented that it adds the most relevent type already?

2) Am I asking for trouble having ObservableCollection when using derived classes?

3) The derived classes all Implement IEditableObject individually however Base does not. My stupidity as at fault because I thought when you implement you would have to define the methods. I can just define them as abstract and then override them in the Derived classes right? If I don't do this will I get into trouble with IEditableCollection.

UPDATE:

I succesfully fixed item 3) base class implements iEditableObject and the throws the abstract virtual methods down to it's derived classes. The addNew method dosesn't work, even if the list is filled with derived item.

I've seen one semi solution. .Net framework 4.0 implements a new method called AddNewItem where you can define the item to be added. Should solve the problem with non parameterless constructer and base classes. However I'm working in 3.5

Anything I can do?