Ejemplo n.º 1
0
		public async Task StartAsync()
		{
			MainViewModel viewModel = new MainViewModel();
			viewModel.CloseRequested += viewModel_CloseRequested;

			EventHandler windowClosed = (sender, e) =>
			{
				viewModel.RequestClose();
			};

			SplashScreen splashScreen = new SplashScreen();  //not disposable, but I'm keeping the same structure
			{
				splashScreen.Closed += windowClosed; //if user closes splash screen, let's quit
				splashScreen.Show();

				await viewModel.InitializeAsync();

				MainWindow mainForm = new MainWindow();
				mainForm.Closed += windowClosed;
				mainForm.DataContext = viewModel;
				mainForm.Show();
				
				splashScreen.Owner = mainForm;
				splashScreen.Closed -= windowClosed;
				splashScreen.Close();
			}
		}
Ejemplo n.º 2
0
        public void Start()
        {
            var viewModel = new MainViewModel();
            viewModel.CloseRequested += viewModel_CloseRequested;
            viewModel.Initialize();

            var mainForm = new MainWindow();
            mainForm.Closed += (sender, e) => { viewModel.RequestClose(); };

            mainForm.DataContext = viewModel;
            mainForm.Show();
            m_app.Run();
        }
Ejemplo n.º 3
0
		public async Task StartAsync()
		{
			MainViewModel viewModel = new MainViewModel();
			viewModel.CloseRequested += viewModel_CloseRequested;
			await viewModel.InitializeAsync();

			MainWindow mainForm = new MainWindow();
			mainForm.Closed += (sender, e) =>
			{
				viewModel.RequestClose();
			};

			mainForm.DataContext = viewModel;
			mainForm.Show();
		}
Ejemplo n.º 4
0
		public async Task StartAsync()
		{
			MainViewModel viewModel = new MainViewModel();
			viewModel.CloseRequested += viewModel_CloseRequested;
			await viewModel.InitializeAsync();

			//this will be on a threadpool thread instead of a ui thread, and won't work
			//it will throw an exception because it's not an STA thread
			MainWindow mainForm = new MainWindow();
			mainForm.Closed += (sender, e) =>
			{
				viewModel.RequestClose();
			};

			mainForm.DataContext = viewModel;
			mainForm.Show(); 
		}