I want to create a scheduler custom control in WPF. Also I want that this control be generic, so for example scheduler can save events about notes, workers, meetings etc.
So I need one interface lets say IContract, which will have SaveEvent(), EditEvent() etc. methods. Every specific class (Note, Meeting...) must implement that interface. Because of that, in my view model for scheduler if I want to save event, I will do that via interface.
But question is, how can I pass this instace ("contract")
IContract contract = new Meeting();
to the scheduler view model? Someone who will use my custom control will just put this peace of code in some XAML
<local:Scheduler/>
Now I can do something like this: <local:Scheduler instanceClass="Meeting"/>
and than in scheduler view model via reflection get instanace. Is that good solution?
Is there another way?
Aucun commentaire:
Enregistrer un commentaire