Beispiel #1
0
        public UniversalInitializer(
            IHostApplicationLifetime lifetime,
            Type mainPageType,
            MainPageContext context)
        {
            if (lifetime is null)
            {
                throw new ArgumentNullException(nameof(lifetime));
            }

            _mainPageType = mainPageType ?? throw new ArgumentNullException(nameof(mainPageType));
            lifetime.ApplicationStarted.Register(() =>
            {
                if (!(Window.Current.Content is Frame frame))
                {
                    frame = new Frame();
                    Window.Current.Content = frame;
                }
                frame.Navigate(_mainPageType, context);
                Window.Current.Activate();
            });
        }
 /// <summary>
 /// Loads new state of ViewModel
 /// </summary>
 private void InitialiazeDataContext()
 {
     this._viewModel = new MainPageContext(App.DbConnectionString);
     this._viewModel.LoadData(0);
     this.DataContext = this._viewModel;
 }