public static LoginPageViewModel GetLoginPageViewModel() { LockingObject = new object(); if (LoginVm == null) { lock (LockingObject) { if (LoginVm == null) { LoginVm = new LoginPageViewModel(); //this LoadHomePage() call out has to be done when homeVM is created, NOT when homeVM is called out. //It can't be done in ctor because, homeVM won't be assinged a value and algorithm becomes indefitely recursive. //Call it out here when homeVM has been assign non-null value, so this part of code won't be reached again. LoginVm.LoadLoginPage(); } } } return(LoginVm); }
/// <summary> /// Updates CurrentViewModel to LoginPageViewModel. If view's DataTemplate and DataContext is binded, then view is changed and control is given over to LoginPageViewModel. /// </summary> protected void LoadLoginPage() { CurrentViewModel = LoginPageViewModel.GetLoginPageViewModel(); }