Skip to content

Latest commit

 

History

History
119 lines (89 loc) · 3.23 KB

wpfintegration.rst

File metadata and controls

119 lines (89 loc) · 3.23 KB

Windows Presentation Foundation Integration Guide

Simple Injector can build up Window classes with their dependencies. Use the following steps as a how-to guide:

Step 1:

Change the App.xaml markup by removing the StartUri property:

<Application x:Class="SimpleInjectorWPF.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!-- Remove the StartupUri property, start the application from a static Main -->
    <Application.Resources>
    </Application.Resources>
</Application>

Step 2:

Add a Program.cs file to your project to be the new entry point for the application:

Step 3:

Change the 'Startup object' in the properties of your project to be the newly created Program class:

'Startup object' settings in the application's properties

Usage

Constructor injection can now be used in any window (e.g. MainWindow) and view model: