private static void SetupWindows() { WindowNavigationService wns = new WindowNavigationService(); wns.Add(WindowNames.MainWindow, new MainWindow()); SimpleIoc.Default.Register <IWindowNavigationService>(() => wns); }
private static void SetupWindows() { WindowNavigationService wns = new WindowNavigationService(); wns.Add(ViewServices.WindowNames.PaymentWindow, new Views.PaymentWindow()); wns.Add(ViewServices.WindowNames.BookSearchWindow, new Views.SearchBooksView()); wns.Add(ViewServices.WindowNames.TransactionWindow, new Views.TransactionWindow()); SimpleIoc.Default.Register <IWindowNavigationService>(() => wns); }
/// <summary> /// This is the entry-piont to the application, which gets called as soon as the application has finished starting up. /// </summary> /// <param name="eventArguments">The event arguments, that contains all necessary information about the application startup like the command line arguments.</param> protected override async Task OnStartedAsync(ApplicationStartedEventArgs eventArguments) { // Initializes the IOC container; in this sample the Simple IOC is used this.iocContainer = new SimpleIocContainer(); // Binds the todo list item repository and some services to the IOC container, so that it can be automatically injected into view models this.iocContainer.RegisterType <IReadOnlyIocContainer>(() => this.iocContainer); this.iocContainer.RegisterType <TodoListItemsRepository>(Scope.Singleton); this.iocContainer.RegisterType <WindowNavigationService>(Scope.Singleton); this.iocContainer.RegisterType <ApplicationService>(Scope.Singleton); this.iocContainer.RegisterType <DialogService>(Scope.Singleton); // Navigates the user to the main view WindowNavigationService windowNavigationService = this.iocContainer.GetInstance <WindowNavigationService>(); await windowNavigationService.NavigateAsync <MainWindow, MainView>(null, true); }
/// <summary> /// Gets called when the app was activated by the user. /// </summary> /// <param name="eventArguments">The event argument, that contain more information on the activation of the application.</param> protected override async Task OnActivatedAsync(IActivatedEventArgs eventArguments) { // Makes sure that the initialization takes only place, when the application was previously not running if (eventArguments.PreviousExecutionState != ApplicationExecutionState.Running && eventArguments.PreviousExecutionState != ApplicationExecutionState.Suspended) { // Initializes the IOC container; in this sample the Simple IOC is used this.iocContainer = new SimpleIocContainer(); // Binds all repositories and services that are needed for the application to the IoC container this.iocContainer.RegisterType <IReadOnlyIocContainer>(() => this.iocContainer); this.iocContainer.RegisterType <TodoListItemsRepository>(Scope.Singleton); this.iocContainer.RegisterType <WindowNavigationService>(Scope.Singleton); this.iocContainer.RegisterType <ApplicationService>(Scope.Singleton); this.iocContainer.RegisterType <DialogService>(Scope.Singleton); // Navigates the user to the main view WindowNavigationService windowNavigationService = this.iocContainer.GetInstance <WindowNavigationService>(); await windowNavigationService.NavigateAsync <MainView>(); } }