/// <summary> /// Initializes a new instance of the <see cref="ViewShell"/> class. /// </summary> /// <param name="frame">A frame.</param> /// <param name="backgroundScheduler">A background scheduler.</param> /// <param name="mainScheduler">A main scheduler.</param> /// <param name="viewTypeLocator">A view locator.</param> public ViewShell(Frame frame, IScheduler backgroundScheduler, IScheduler mainScheduler, ViewTypeLocator viewTypeLocator) { _frame = frame; _backgroundScheduler = backgroundScheduler ?? RxApp.TaskpoolScheduler; _mainScheduler = mainScheduler ?? RxApp.MainThreadScheduler; _viewTypeLocator = viewTypeLocator ?? new ViewTypeLocator(); _pagePopped = new Subject <IPageViewModel>(); HorizontalContentAlignment = HorizontalAlignment.Stretch; VerticalContentAlignment = VerticalAlignment.Stretch; Observable.FromEventPattern <NavigatedEventHandler, NavigationEventArgs>( h => frame.Navigated += h, h => frame.Navigated -= h) .Do( e => { var viewFor = e.EventArgs.Content as IViewFor; viewFor.ViewModel = e.EventArgs.Parameter; }); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); //TODO: Understand how to check if DB schema not matching context //calling on all sets FirstOrDefault()? partsContext = new PartsContext(); ViewTypeLocator viewTypeLocator = new ViewTypeLocator(); viewTypeLocator.Register <MainViewModel, MainView>(); viewTypeLocator.Register <AddEntityViewModel <Part, PartsMapping>, AddEntityView>(); viewTypeLocator.Register <EditEntityViewModel <Part, PartsMapping>, EditEntityView>(); IDialogService dialogService = new DialogService(dialogTypeLocator: viewTypeLocator); MainViewModel mainViewModel = new MainViewModel(dialogService, partsContext); MainView mainView = new MainView { DataContext = mainViewModel }; mainView.Show(); }