/// <summary> /// Initialize ibject states upon construction /// </summary> private void InitObject() { this.OnSessionEnding = null; this.mDialogCloseResult = null; this.mIsReadyToClose = false; this.mShutDownInProgress = false; this.mTestDialogViewModel = new UsernameViewModel(); }
/// <summary> /// Copy constructor /// </summary> public UsernameViewModel(UsernameViewModel copyThis) : this() { if (copyThis == null) { return; } this.mOpenCloseView = new DialogViewModelBase(copyThis.mOpenCloseView); }
/// <summary> /// Show a dialog that is closed via corresponding viewmodel and attached behaviour. /// </summary> public void ShowUserNameDialog() { UsernameViewModel dlgVM = null; try { dlgVM = new UsernameViewModel(this.mTestDialogViewModel); // It is important to either: // 1> Use the InitDialogInputData methode here or // 2> Reset the WindowCloseResult=null property // because otherwise ShowDialog will not work twice // (Symptom: The dialog is closed immeditialy by the attached behaviour) dlgVM.InitDialogInputData(); // Showing the dialog, alternative 1. // Showing a specified dialog. This doesn't require any form of mapping using // IWindowViewModelMappings. dialogService.ShowDialog(this, dlgVM); // Copy input if user OK'ed it. This could also be done by a method, equality operator, or copy constructor if (dlgVM.OpenCloseView.WindowCloseResult == true) { Console.WriteLine("Dialog was OK'ed."); //this.mTestDialogViewModel.FirstName = dlgVM.FirstName; //this.mTestDialogViewModel.LastName = dlgVM.LastName; IsReadyToClose = true; } else { IsReadyToClose = false; Console.WriteLine("Dialog was Cancel'ed."); } // Showing the dialog, alternative 2. // Showing a dialog without specifying the type. This require some form of mapping using // IWindowViewModelMappings. //dialogService.ShowDialog(this, personDialogViewModel); } catch (Exception exc) { MessageBox.Show(exc.ToString()); } }