PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

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

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