/*
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 MuchInfo.Chart.App.Services;
namespace MuchInfo.Chart.App.ViewModels
{
///
/// This class contains static references to all the view models in the
/// application and provides an entry point for the bindings.
///
/// See http://www.galasoft.ch/mvvm
///
///
public class ViewModelLocator
{
static ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
//注册服务
if (ViewModelBase.IsInDesignModeStatic)
{
//in Blend
// SimpleIoc.Default.Register();
}
else
{
//In Visual Studio
// SimpleIoc.Default.Register();
SimpleIoc.Default.Register();
}
SimpleIoc.Default.Register();
}
///
/// Gets the Main property.
///
public MainViewModel Main
{
get
{
return ServiceLocator.Current.GetInstance();
}
}
}
}