Beispiel #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWindow window = new MainWindow();

            // Create the ViewModel to which 
            // the main window binds.
            string path = "Data/customers.xml";
            var viewModel = new MainWindowViewModel(path);

            // When the ViewModel asks to be closed, 
            // close the window.
            EventHandler handler = null;
            handler = delegate
            {
                viewModel.RequestClose -= handler;
                window.Close();
            };
            viewModel.RequestClose += handler;

            // Allow all controls in the window to 
            // bind to the ViewModel by setting the 
            // DataContext, which propagates down 
            // the element tree.
            window.DataContext = viewModel;

            window.Show();
        }
Beispiel #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWindow window = new MainWindow();
            var viewModel = new MainWindowViewModel();
            window.DataContext = viewModel;
            window.Show();
        }
Beispiel #3
0
		protected override void OnStartup( StartupEventArgs e )
		{
			base.OnStartup( e );

			MainWindow window = new MainWindow( );

			string path = @"C:\Trabajos\Conferencias\RUN 09 - Arquitecturas de presentacion con WPF\Samples\MvvmDemoApp_Spanish\DemoApp\bin\Debug\customers.xml";
			var viewModel = new MainWindowViewModel( path );

			EventHandler handler = null;
			handler = delegate
			{
				viewModel.RequestClose -= handler;
				window.Close( );
			};
			viewModel.RequestClose += handler;

			window.DataContext = viewModel;

			window.Show( );

			if ( e.Args != null && e.Args.GetUpperBound( 0 ) == 0 )
			{
				if ( e.Args[ 0 ] == ViewAllCustomerArg )
				{
					viewModel.ShowAllCustomers( );
				}
				else
				{
					string[] customerData = Path.GetFileNameWithoutExtension( e.Args[ 0 ].Replace( "/doc", String.Empty ) ).Split( '_' );

					if ( customerData.GetUpperBound( 0 ) == 0 )
						viewModel.ShowCustomer( customerData[ 0 ], null );
					else
						viewModel.ShowCustomer( customerData[ 0 ], customerData[ 1 ] );
				}
			}
		}