ayy lmao
This commit is contained in:
parent
abbe94a72c
commit
3b1afdf2c0
92 changed files with 23248 additions and 0 deletions
63
WPFCatalog/ViewModel/ViewModelLocator.cs
Normal file
63
WPFCatalog/ViewModel/ViewModelLocator.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
In App.xaml:
|
||||
<Application.Resources>
|
||||
<vm:ViewModelLocator xmlns:vm="clr-namespace:WPFCatalog"
|
||||
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 GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
|
||||
namespace WPFCatalog.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>();
|
||||
}
|
||||
|
||||
public MainViewModel Main
|
||||
{
|
||||
get
|
||||
{
|
||||
return ServiceLocator.Current.GetInstance<MainViewModel>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void Cleanup()
|
||||
{
|
||||
// TODO Clear the ViewModels
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue