static void Main()
        {
            //the WPF application object will be the main UI loop
            System.Windows.Application wpfApplication = new System.Windows.Application
            {
                //otherwise the application will close when all WPF windows are closed
                ShutdownMode = ShutdownMode.OnExplicitShutdown
            };
            SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());

            //set the WinForms properties
            //notice how you don't need to do anything else with the Windows Forms Application (except handle exceptions)
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            WpfProgramAddWinForms p = new WpfProgramAddWinForms();

            p.ExitRequested += (sender, e) =>
            {
                wpfApplication.Shutdown();
            };

            Task programStart = p.StartAsync();

            HandleExceptions(programStart, wpfApplication);

            wpfApplication.Run();
        }
示例#2
0
		static void Main()
		{
			//the WPF application object will be the main UI loop
			System.Windows.Application wpfApplication = new System.Windows.Application
			{
				//otherwise the application will close when all WPF windows are closed
				ShutdownMode = ShutdownMode.OnExplicitShutdown 
			};
			SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());

			//set the WinForms properties
			//notice how you don't need to do anything else with the Windows Forms Application (except handle exceptions)
			System.Windows.Forms.Application.EnableVisualStyles();
			System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
			
			WpfProgramAddWinForms p = new WpfProgramAddWinForms();
			p.ExitRequested += (sender, e) =>
			{
				wpfApplication.Shutdown();
			};

			Task programStart = p.StartAsync();
			HandleExceptions(programStart, wpfApplication);

			wpfApplication.Run();
		}