I have hit a wall. I have added a reference of another assembly that has Service classes. So instead of creating a new instance i though that MEF would help(but wont).. I do something similar to HelloScreens sample.The following viewmodel accepts a property too that holds the model.(Staff)
public class StaffFormViewModel : Screen
{
[Import]
public StaffService staffService { get; set; }
Obviously this doesnt work as the class isnt constructed by MEF. But even i wanted to construct it with mef i should create multiple instances so i should select NonShared.But people say its slow. Caliburn micro example adds something like this in order to create new instances. This requires 5 lines of code for each thing.
batch.AddExportedValue<Func<PreferencesCategoriesFormViewModel>>(
() => container.GetExportedValue<PreferencesCategoriesFormViewModel>());
The problem is that although i can use this then if i want to provide a model class at constructor I cant because it is constructed by MEF. I should set the property by hand. All i wanted is to inject the needed service. Isnt this possible with mef? Should i have public static the container so i can reference it and call compose? Please help :)