Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4061162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:25:55+00:00 2026-05-20T15:25:55+00:00

My request is similar to this . I am using MvvmLight and the Viewmodel

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:25:55+00:00Added an answer on May 20, 2026 at 3:25 pm

    The problem is that Blend does not execute all the code. To check this out, you can attach a debugger (from Visual Studio 10 to Blend 4, making sure that you select Managed Code V4.0) and place a breakpoint in your setup code. Probably it does not get called.

    To solve this, you can try and do the setup in the ViewModelLocator. Since the VML is created in the App.xaml resources, Blend is running that code. You can, for example, put the setup code in the static VML constructor.

    Cheers,
    Laurent

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar to: Request Windows Vista UAC elevation if path is protected? I have a
This request is based in MS Access VBA. I would like to know what
I'm using httpc:request to post some data to a remote service. I have the
another request sorry.. Right now I am reading the tokens in one by one
How can I request a random row (or as close to truly random as
There is a request to make the SO search default to an AND style
If I pass request fields or cookies with a period/dot in their names, PHP
I Have a request for the TOTAL's and subtotals column to be moved to
I've got a request from a customer to automatically detect the type of mobile
I'm making a request from an UpdatePanel that takes more then 90 seconds. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.