So I have 4 classes, for example:
Class A Inherits I
Public name as String
Public ID as Integer
Class B Inherits I
Public test as String
Public somethingElse as Integer
Class C Inherits I
Public banana as String
Public Type as String
Public length as Integer
Class D Inherits I
Public name as String
Public ID as String
Say I have a ComboBox in my WPF application that contains a list of I objects (some are of type Class A, some of type Class C, etc etc etc.).
When one is selected, I want the datagrid to populate with the public variables of the selected class - variable names in the left column and values in the right.
I want the right-hand column to be editable, but not to update the variables in the class directly.
My questions are, then - how do I bind the datagrid to the selected class if all/some of the variables are different in each class? And how do I then keep the association with the variable, so I can update it later if the changes the user makes passes my custom validation?
My idea (that I don't know how to implement):
Would each class need some sort of converter method that the DataGrid can bind to? but if so, what would that method return?
Would I just have to keep track that row 1 contains this variable, etc. for each class, so I can update later?