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

  • SEARCH
  • Home
  • 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 121267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:56:38+00:00 2026-05-11T03:56:38+00:00

I am trying to put all the pieces together for my MVVM Silverlight application

  • 0

I am trying to put all the pieces together for my MVVM Silverlight application and I see some blogs touch on Service Locators.

What is a service locator and when should it be used?

  • 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. 2026-05-11T03:56:38+00:00Added an answer on May 11, 2026 at 3:56 am

    I’ve used ServiceLocator in combination with MVVM to enable declarative binding from the View to the ViewModel.

    The ServiceLocator is pull-based while IoC containers are push-based. For instance:

    If you use an IoC container you’ll probably create something like this:

    public MyViewModel(IDataRepository repository) { } 

    The IoC container will push the IDataRepository instance into the object while constructing it.

    If you use a ServiceLocator you will typically write code like this:

    public MyViewModel() {     _repository = ServiceLocator.Instance.DataRepository; } 

    So in this case the ViewModel is pulling an instance of the IDataRepository interface from the ServiceLocator.

    The ServiceLocator might be backed by a IoC container (but not necessary).

    The benefit of doing this is that you can add the ServiceLocator as a resource to your App.xaml file, and then access it declaratively from views.

    <UserControl      DataContext='{Binding Path=MyViewModel,                    Source={StaticResource serviceLocator}}'>...</UserControl> 

    The MyViewModel might be created by a IoC container, but it’s pulled into the View using data binding and a ServiceLocator.

    I have a blog post about Dependency Injection, IoC and ServiceLocators in a Silverlihgt/MVVM context over at my blog.

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

Sidebar

Related Questions

I am trying to learn or put together the bits and pieces that I
I've been trying to put the pieces together on this for a while and
I am trying to make a movie with openCV. I can put all the
I am trying to pull registry info from many servers and put them all
I've been at this all week, trying to put the finishing touches on my
Trying to put a regex expression together that returns the string between _ and
I trying to put together an Android app that will take a picture and
I'm trying to put together a script to monitor the MSMQ on a server.
I'm trying to put some custom list adapters into their own classes to make
Greetings, I'm trying to draw a circle on a map. all the separate pieces

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.