WPF and Inversion of Control: Listing 3.

The App.xaml.cs file.

private static readonly WindsorContainer container = new WindsorContainer();
 
public App()
{
  ConfigureContainer();
}
 
private void ConfigureContainer()
{
  container.AddFacility<ViewActivatorFacility>();
  container.Register(
    AllTypes.FromThisAssembly().BasedOn<IView>()
    .WithService.FromInterface()
    .Configure(c => c.LifeStyle.Is(LifestyleType.Transient)),

    AllTypes.FromThisAssembly().BasedOn<IViewModel>()
    .Configure(c => c.LifeStyle.Is(LifestyleType.Transient))
    );
}

About the Author

Patrick Steele is a senior .NET developer with Billhighway in Troy, Mich. A recognized expert on the Microsoft .NET Framework, he’s a former Microsoft MVP award winner and a presenter at conferences and user group meetings.

comments powered by Disqus

Featured

  • New TypeScript 4.2 Tweaks Include Project Explainer

    Microsoft shipped TypeScript 4.2 -- the regular quarterly update to the open source programming language that improves JavaScript with static types -- with a host of tweaks including a way to explain why files are included in a project.

  • What's Top-Paying .NET Skill, In-Demand Language?

    New tech reports reveal the top-paying .NET skills and most in-demand programming languages in the Microsoft-centric developer landscape.

  • Microsoft's Distributed Application Runtime (Dapr) Debuts for Microservices

    Dapr is now production ready in version 1.0, easing microservices development on-premises, on the edge or in the cloud by abstracting away distributed computing hassles.

  • What's New in EF Core 6.0 Preview 1

    The Entity Framework Core 6 dev team shipped Preview 1 this week, headed toward a debut with the larger, unifying .NET 6 umbrella platform in November.

Upcoming Events