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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:15:24+00:00 2026-06-10T10:15:24+00:00

I am attempting to translate a WPF example of IOC using StructureMap into Silverlight

  • 0

I am attempting to translate a WPF example of IOC using StructureMap into Silverlight using AutoFac

This is proving to be very difficult

I have got a static BootStrapper class defined

public class BootStrapper
{
  public static IContainer BaseContainer { get; private set; }

  public static FlexContractStructureViewModel FlexContractStructureViewModel()
  {
      return BaseContainer.Resolve<FlexContractStructureViewModel>();
  }

  public static void Build()
  {
      if (BaseContainer == null)
      {
          var builder = new ContainerBuilder();
          builder.RegisterAssemblyTypes();

          BaseContainer = builder.Build();
      }
  }

  static BootStrapper()
  {

  }

} 

This is initialised in the Application_Startup in App.xaml.cs

private void Application_Startup(object sender, StartupEventArgs e)
{
  BootStrapper.Build();

  this.RootVisual = new MainPage();
}

I have set the DataContext of one of my views to use my BootStrapper

DataContext="{Binding Path=FlexContractStructureViewModel, 
              Source={StaticResource classes:BootStrapper}}"          

But I get the error Cannot find a Resource with the Name/Key classes:BootStrapper

The book I am using states to make a change to the App.xaml to add

But I cant do that because ObjectDataProvider is not recognised

I have tried the equivalent below with no luck

<bs:BootStrapper xmlns:bs="clr-namespace:SLDashboard2.Classes" x:Key="BootStrapper"/>

I think this may be related to having BootStrapper static? But I dont want to be constantly creating new Containers

Can someone help please?

Paul

  • 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-06-10T10:15:26+00:00Added an answer on June 10, 2026 at 10:15 am

    Wrong. Shouldn’t you be registering all your ViewModels in your IoC? and then you inject them to your constructors. They should never be static and I don’t usually use static resources as my datacontext in my view

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

Sidebar

Related Questions

I'm attempting to embed the very convenient Google Translate translate element into a webpage,
I have been attempting to split a div into two columns using CSS, but
I'm attempting to translate an existing Access report into a client-side SSRS 2008 report,
Attempting to use the data series from this example no longer passes the JSONLint
I have recently gone into extending my site using node.js and have come to
I'm attempting to translate the following C# code into IronPython but I don't know
I'm attempting to translate some English text to Chinese using Bing Translate's API. My
I am attempting to translate two separate algorithms into Java code in order to
I'm attempting to translate some C++ code into Java. I'm looking for the best
I am attempting to translate or convert these functions from a .asp file into

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.