Is there a way to have collection of objects which do not have a parameter less constructor and still be able to have the "Add" functionality of Silverlight dataform working.
In my case, I have a class for e.g. Customer and it does not have a parameterless constructor.
When a collection of this class (ObservableCollection) is data bound to a silverlight DataForm, "Add" button gets disabled as the Customer class does not have a parameterless constructor.
I cannot have a parameterless constructor for this class as it has dependencies that are injected from outside that are required on instantiation.
<toolkit:DataForm AutoGenerateFields="False" AutoCommit="True" CommandButtonsVisibility="All" CurrentItem="{Binding SelectedCustomer, Mode=TwoWay}"
ItemsSource="{Binding CustomersCollection}" />
Are there any solutions/work-arounds to get this working?
Your suggestions are highly appreciated.
As it appears, the parematerless contructor is required for the Add button to get enabled.
A possible alternative of getting the dependencies injected would be to use property injection rather than constructor injection through a DI container. (Haven't tried it though, but I presume it would work. )