/*
In App.xaml:
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 System;
using CommonServiceLocator;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Domain.Interfaces;
using GalaSoft.MvvmLight;
namespace ModernKeePass.ViewModels
{
///
/// This class contains static references to all the view models in the
/// application and provides an entry point for the bindings.
///
public class ViewModelLocator: ViewModelLocatorCommon
{
///
/// Initializes a new instance of the ViewModelLocator class.
///
public ViewModelLocator()
{
if (ViewModelBase.IsInDesignModeStatic)
{
// Create design time view services and models
//SimpleIoc.Default.Register();
}
else
{
// Create run time view services and models
//SimpleIoc.Default.Register();IDataService
SimpleIoc.Default.Register(() => App.Services.GetRequiredService());
}
SimpleIoc.Default.Register();
SimpleIoc.Default.Register();
SimpleIoc.Default.Register();
SimpleIoc.Default.Register();
}
public MainVm Main => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString());
public SettingsVm Settings => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString());
public GroupDetailVm Group => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString());
public EntryDetailVm Entry => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString());
}
}