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 613887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:03:07+00:00 2026-05-13T18:03:07+00:00

Ok, I’m pulling my hair out over this, so any help will be hugely

  • 0

Ok, I’m pulling my hair out over this, so any help will be hugely appreciated!

I’m building a WPF application using the MVVM pattern.

In an attempt to get data in at design time I am using the Ninject dependency injection framework in conjunction with a service locator (much like the example in an article at http://jonas.follesoe.no/YouCardRevisitedImplementingDependencyInjectionInSilverlight.aspx

(as I’m using WPF and not Silverlight I check for design time properties slightly differently but otherwise I believe it is applicable).

I can’t get it to work at design time, no matter what I do the binding doesn’t seem to even get called. It works fine at runtime.

Here’s the code for my Ninject module:

public class ViewModelModule : StandardModule
{
    public override void Load()
    {
        bool isRuntime = !ViewModelBase.IsInDesignMode;

        if (isRuntime)
        {
            Bind<IViewModel>().To<MyViewModel>();                
        }
        else
        {
            Bind<IViewModel>().To<MyDesignTimeViewModel>();
        }
    }
}

MyDesignTimeViewModel is a plain CLR object that returns hardcoded data in place of all the same properties on MyViewModel.

The Service Locator is as follows:

 public class ViewModelLocator
 {
    private static IKernel kernel;

    static ViewModelLocator()
    {
        if (kernel == null)
        {
            kernel = new StandardKernel(new ViewModelModule());
        }
    }      

    public IViewModel ViewModel
    {
        get
        {
            var vm = kernel.Get<IViewModel>();
            return vm;
        }
    }
}

And the XAML binds the DataContext of the page as follows (though I’ve tried a few different ways of declaring it, all with the same result):

<Page.DataContext>
    <Binding Source="{StaticResource viewModelLocator}" Path="ViewModel" />        
</Page.DataContext>

(where the viewModelLocator is declared in a ResourceDictionary that is merged at the top of this file).

As I said this works fine at runtime, even if I switch my Ninject binding to use MyDesignTimeViewModel at runtime it successfully displays the dummy data. I’ve got a dummy converter in one of my bindings to see what gets passed through and this gets called at runtime but not at design time (I’ve been frantically debugging a design time instance using a seperate Visual Studio process all day, as per the MSDN recommendations!)

At design time the Ninject binding goes ahead, along with the kernel instantiation. Then the viewModel gets called for and it returns a DesignTimeViewModel, along with all my hardcoded data. But the actual binding to any of the properties on the viewmodel never seem to get called (the dummy converter breakpoint never gets hit).

I really can’t see what I’m doing wrong. Any pointers in any direction would be greatly appreciated as at this stage I’m just baffled. Thanks 🙂

  • 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-13T18:03:08+00:00Added an answer on May 13, 2026 at 6:03 pm

    Here are couple things to try:

    1. While you are debugging designer, check whether you have any warnings/errors.
    2. Try to snoop your designer with latest version of Snoop, which allows you to attach to the Visual Studio.
    3. Try to debug bindings. Maybe something interesting comes out.

    And don’t forget to check DataContexts :).

    Hope at least something would help.

    Cheers

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.