You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.7 KiB
104 lines
2.7 KiB
/*
|
|
In App.xaml:
|
|
<Application.Resources>
|
|
<vm:ViewModelLocator xmlns:vm="clr-namespace:Audit"
|
|
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 CommonServiceLocator;
|
|
using GalaSoft.MvvmLight;
|
|
using GalaSoft.MvvmLight.Ioc;
|
|
|
|
|
|
namespace Audit.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
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the ViewModelLocator class.
|
|
/// </summary>
|
|
public ViewModelLocator()
|
|
{
|
|
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
|
|
|
|
////if (ViewModelBase.IsInDesignModeStatic)
|
|
////{
|
|
//// // Create design time view services and models
|
|
//// SimpleIoc.Default.Register<IDataService, DesignDataService>();
|
|
////}
|
|
////else
|
|
////{
|
|
//// // Create run time view services and models
|
|
//// SimpleIoc.Default.Register<IDataService, DataService>();
|
|
////}
|
|
|
|
SimpleIoc.Default.Register<MainViewModel>();
|
|
SimpleIoc.Default.Register<LogViewModel>();
|
|
SimpleIoc.Default.Register<StatisticsViewModel>();
|
|
SimpleIoc.Default.Register<QueryViewModel>();
|
|
}
|
|
|
|
///<Summary>
|
|
/// MainViewModel
|
|
///</Summary>
|
|
public MainViewModel Main
|
|
{
|
|
get
|
|
{
|
|
return ServiceLocator.Current.GetInstance<MainViewModel>();
|
|
}
|
|
}
|
|
|
|
///<Summary>
|
|
/// LogViewModel
|
|
///</Summary>
|
|
public LogViewModel Login
|
|
{
|
|
get
|
|
{
|
|
return ServiceLocator.Current.GetInstance<LogViewModel>();
|
|
}
|
|
}
|
|
|
|
///<Summary>
|
|
/// StatisticsViewModel
|
|
///</Summary>
|
|
public StatisticsViewModel Statistics
|
|
{
|
|
get
|
|
{
|
|
return ServiceLocator.Current.GetInstance<StatisticsViewModel>();
|
|
}
|
|
}
|
|
|
|
///<Summary>
|
|
/// QueryViewModel
|
|
///</Summary>
|
|
public QueryViewModel Query
|
|
{
|
|
get
|
|
{
|
|
return ServiceLocator.Current.GetInstance<QueryViewModel>();
|
|
}
|
|
}
|
|
|
|
///<Summary>
|
|
/// Cleanup
|
|
///</Summary>
|
|
public static void Cleanup()
|
|
{
|
|
// TODO Clear the ViewModels
|
|
}
|
|
}
|
|
}
|