My request is similar to this.
I am using MvvmLight and the Viewmodel information shows properly for designtime and runtime. However I want to abstract it away into a Service class. So I have my Mock Service and the real Service that both Implement IService.
in the codebehind for app.xaml I am checking for designtime, then calling the method on my serviceloader depending on what the check returns.
if (IsInDesignModeStatic)
{
ServiceLoader.LoadDesignTimeServices();
}
else
{
ServiceLoader.LoadRunTimeServices();
}
public sealed class ServiceLoader
{
private ServiceLoader()
{
}
public static void LoadDesignTimeServices()
{
ServiceContainer.Instance.AddService<IQuestionsService>(new dt.QuestionsService());
}
public static void LoadRunTimeServices()
{
ServiceContainer.Instance.AddService<IQuestionsService>(new rt.QuestionsService());
}
}
This works in Runtime just fine, but not in designtime. If I actually use the designtime concrete implementation in my viewmodel:
if (IsInDesignMode)
{
//var s = Infrastructure.GetService<IQuestionsService>();
var s = new ReadmissionTrackingApplication.Client.Services.DesignTime.QuestionsService();
QuestionCollectionView_Refresh(s.getQuestions());
}
else
{
//Listens for New Questionairre request. It receives the current ReadmitPatientResult
Messenger.Default.Register<fnReadmitPatientList_Result>(this, ReceiveNewQuestionairreRequest);
//TODO for testing only
ReceiveNewQuestionairreRequest(null);
}
it shows up in Blend. What do I need to do to allow access to the mock service in blend? I think I remember reading I have to somehow add the serviceloader to my application resources similar to what is done with the viewmodels...but I dont know exactly how it needs to be done, I assume its different from how the vm is done, because I am not accessing the service in the view but from the viewmodel.