/* 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; 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() { 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()); } }