/*
In App.xaml:
In the View:
DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
*/
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;
using Editor.Model;
namespace Editor.ViewModel
{
///
/// This class contains static references to all the view models in the
/// application and provides an entry point for the bindings.
///
/// Use the mvvmlocatorproperty snippet to add ViewModels
/// to this locator.
///
///
/// See http://www.galasoft.ch/mvvm/getstarted
///
///
public class ViewModelLocator
{
static ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
if (ViewModelBase.IsInDesignModeStatic)
{
SimpleIoc.Default.Register();
}
else
{
SimpleIoc.Default.Register();
}
SimpleIoc.Default.Register();
}
///
/// Gets the Main property.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
"CA1822:MarkMembersAsStatic",
Justification = "This non-static member is needed for data binding purposes.")]
public MainViewModel Main
{
get
{
return ServiceLocator.Current.GetInstance();
}
}
///
/// Cleans up all the resources.
///
public static void Cleanup()
{
}
}
}