using System; using Stylet; using StyletIoC; using Stylet.Samples.NavigationController.Pages; namespace Stylet.Samples.NavigationController { public class Bootstrapper : Bootstrapper { protected override void ConfigureIoC(IStyletIoCBuilder builder) { builder.Bind().And().To().InSingletonScope(); // https://github.com/canton7/Stylet/issues/24 builder.Bind>().ToFactory>(c => () => c.Get()); builder.Bind>().ToFactory>(c => () => c.Get()); } protected override void OnLaunch() { // There's a circular dependency, where ShellViewModel -> HeaderViewModel -> NavigationController -> ShellViewModel // We break this by assigning the ShellViewModel to the NavigationController after constructing it var navigationController = this.Container.Get(); navigationController.Delegate = this.RootViewModel; navigationController.NavigateToPage1(); } } }