PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/App.xaml.cs

https://github.com/shader/QuickArch
C# | 43 lines | 28 code | 6 blank | 9 comment | 0 complexity | f5b8e374f1d9f0c9712f4033ec1f02dc MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Windows;
  7. using QuickArch.ViewModel;
  8. namespace QuickArch
  9. {
  10. /// <summary>
  11. /// Interaction logic for App.xaml
  12. /// </summary>
  13. public partial class App : Application
  14. {
  15. protected override void OnStartup(StartupEventArgs e)
  16. {
  17. base.OnStartup(e);
  18. MainWindow window = new MainWindow();
  19. //Create the ViewModel to which the main window binds
  20. //string path = "Data/components.xml"
  21. var viewModel = new MainWindowViewModel();
  22. //When the ViewModel asks to be closed, close the window.
  23. EventHandler handler = null;
  24. handler = delegate
  25. {
  26. viewModel.RequestClose -= handler;
  27. window.Close();
  28. };
  29. viewModel.RequestClose += handler;
  30. //allow all controls in the window to
  31. //bind to the viewModel by setting the
  32. //DataContext, which propagates down the element tree
  33. window.DataContext = viewModel;
  34. window.Show();
  35. }
  36. }
  37. }