A simple example of using dependency injection using Unity in WPF
Step 1: Create a new Visual Studio project Step 2: Add the necessary Unity reference Select Tools > NuGet Package Manager. Type in the following command: [code language="txt"] Install-Package Unity -Version 4.0.1 [/code] Unity website for NuGet can be found here: https://www.nuget.org/packages/Unity/ Step 3: Remove the startup URL In App.xaml get rid of the StartupUri value: Step 4: Add the Model class / interface IModel.cs [code language="csharp"] namespace DependencyInjection { public interface IModel { } } [/code] Model.cs [code language="csharp"] namespace DependencyInjection { public class Model : IModel { public Model() { Text = "Hello"; } public string Text { get; set; } } } [/code] Step 5: Add the ViewModel class To deal with the error that we receive in the XAML when a ViewModel has "No parameterless constructor defined for this object" ...