Adding objects using the adddew () method of IEditableCollectionView is pretty decent. However, I'm not sure how well it works with my shared code, which I have.
I have an ObservableCollection of my base class. Depending on what the user wants to see, it may be populated with DerivedA or DerivedB (or mutliple of other classes of the derived type). It never has more than 1 type. I have the following questions about this since the main issue is number 1.
1) What type of object is added when the addNew () method is called. I guess the base, but not sure. What if the base is abstract? Is there anyway I can guarantee that it will add a specific type or is it implemented that it adds the most suitable type already?
2) I ask about a problem with ObservableCollection when using derived classes?
3) Derived classes all implement IEditableObject individually, but Base does not. My stupidity is to blame, because I thought that when you implement, you will have to define methods. Can I just define them as abstract and then override them in Derived classes correctly? If I do not, I will have problems with IEditableCollection.
UPDATE:
I successfully captured an element 3) the base class implements iEditableObject and casts abstract virtual methods to its derived classes. The addNew method does not work, even if the list is populated with a derived item.
I saw one semi solution .. Net framework 4.0 implements the new AddNewItem method in which you can define the element to be added. Should solve a problem with a parallelless constructor and base classes. However, I work in 3.5
What can I do?
source
share