PageRenderTime 76ms CodeModel.GetById 26ms RepoModel.GetById 10ms app.codeStats 0ms

/Source/Bifrost.Mimir/ViewModel/ViewModelLocator.cs

#
C# | 58 lines | 22 code | 5 blank | 31 comment | 0 complexity | e2a0d9d5170285d6f47d20cf0d448647 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. /*
  2. In App.xaml:
  3. <Application.Resources>
  4. <vm:ViewModelLocatorTemplate xmlns:vm="clr-namespace:Bifrost.Mimir"
  5. x:Key="Locator" />
  6. </Application.Resources>
  7. In the View:
  8. DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
  9. You can also use Blend to do all this with the tool's support.
  10. See http://www.galasoft.ch/mvvm
  11. */
  12. using GalaSoft.MvvmLight;
  13. namespace Bifrost.Mimir.ViewModel
  14. {
  15. /// <summary>
  16. /// This class contains static references to all the view models in the
  17. /// application and provides an entry point for the bindings.
  18. /// </summary>
  19. public class ViewModelLocator
  20. {
  21. private static MainViewModel _main;
  22. /// <summary>
  23. /// Initializes a new instance of the ViewModelLocator class.
  24. /// </summary>
  25. public ViewModelLocator()
  26. {
  27. ////if (ViewModelBase.IsInDesignModeStatic)
  28. ////{
  29. //// // Create design time services and viewmodels
  30. ////}
  31. ////else
  32. ////{
  33. //// // Create run time services and view models
  34. ////}
  35. _main = new MainViewModel();
  36. }
  37. /// <summary>
  38. /// Gets the Main property which defines the main viewmodel.
  39. /// </summary>
  40. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
  41. "CA1822:MarkMembersAsStatic",
  42. Justification = "This non-static member is needed for data binding purposes.")]
  43. public MainViewModel Main
  44. {
  45. get
  46. {
  47. return _main;
  48. }
  49. }
  50. }
  51. }