mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-20 09:32:54 +01:00
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
// <copyright file="ViewModelLocator.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
|
|
|
/*
|
|
In App.xaml:
|
|
<Application.Resources>
|
|
<vm:ViewModelLocator xmlns:vm="clr-namespace:FileConverter"
|
|
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
|
|
*/
|
|
|
|
namespace FileConverter.ViewModels
|
|
{
|
|
using System;
|
|
|
|
using CommonServiceLocator;
|
|
|
|
using FileConverter.Views;
|
|
|
|
using GalaSoft.MvvmLight.Ioc;
|
|
using GalaSoft.MvvmLight.Views;
|
|
|
|
/// <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<HelpViewModel>();
|
|
SimpleIoc.Default.Register<MainViewModel>();
|
|
SimpleIoc.Default.Register<UpgradeViewModel>();
|
|
SimpleIoc.Default.Register<SettingsViewModel>();
|
|
SimpleIoc.Default.Register<DiagnosticsViewModel>();
|
|
}
|
|
|
|
public HelpViewModel Help => ServiceLocator.Current.GetInstance<HelpViewModel>();
|
|
|
|
public MainViewModel Main => ServiceLocator.Current.GetInstance<MainViewModel>();
|
|
|
|
public UpgradeViewModel Upgrade => ServiceLocator.Current.GetInstance<UpgradeViewModel>();
|
|
|
|
public SettingsViewModel Settings => ServiceLocator.Current.GetInstance<SettingsViewModel>();
|
|
|
|
public DiagnosticsViewModel Diagnostics => ServiceLocator.Current.GetInstance<DiagnosticsViewModel>();
|
|
}
|
|
} |