/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
- /*
- In App.xaml:
- <Application.Resources>
- <vm:ViewModelLocatorTemplate xmlns:vm="clr-namespace:Bifrost.Mimir"
- x:Key="Locator" />
- </Application.Resources>
-
- In the View:
- DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
-
- You can also use Blend to do all this with the tool's support.
- See http://www.galasoft.ch/mvvm
- */
-
- using GalaSoft.MvvmLight;
-
- namespace Bifrost.Mimir.ViewModel
- {
- /// <summary>
- /// This class contains static references to all the view models in the
- /// application and provides an entry point for the bindings.
- /// </summary>
- public class ViewModelLocator
- {
- private static MainViewModel _main;
-
- /// <summary>
- /// Initializes a new instance of the ViewModelLocator class.
- /// </summary>
- public ViewModelLocator()
- {
- ////if (ViewModelBase.IsInDesignModeStatic)
- ////{
- //// // Create design time services and viewmodels
- ////}
- ////else
- ////{
- //// // Create run time services and view models
- ////}
-
- _main = new MainViewModel();
- }
-
- /// <summary>
- /// Gets the Main property which defines the main viewmodel.
- /// </summary>
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
- "CA1822:MarkMembersAsStatic",
- Justification = "This non-static member is needed for data binding purposes.")]
- public MainViewModel Main
- {
- get
- {
- return _main;
- }
- }
- }
- }