private void VM_ChangeMainWindow(ViewModel.MainControlChangeEventArgs _args) { ViewModel.MainViewModelBase newViewModelBase; newViewModelBase = (ViewModel.MainViewModelBase)Activator.CreateInstance(_args.NewViewModel, _args.args); // newViewModelBase = (ViewModel.MainViewModelBase)Activator.CreateInstance(_args.NewViewModel); if (!newViewModelBase.IsReady()) { return; } UserControl newUserControl = (UserControl)Activator.CreateInstance(_args.NewUserControl); this.mainContent = newUserControl; this.mainContentViewModel = newViewModelBase; this.mainContent.DataContext = this.mainContentViewModel; this.mainContentViewModel.ChangeMainWindowContent += new ViewModel.Event_mainControlChange(VM_ChangeMainWindow); }
public MainWindowViewModel() { // this.mainContent = new View.QnA(); this.mainContent = new View.MainUserControl(); this.mainContentViewModel = new ViewModel.MainUserControlViewModel(); this.mainContent.DataContext = this.mainContentViewModel; this.Command_ChangeLanguage = new DelegateCommand(x => this.Execute_ChangeLanguage((int)x)); this.Command_NewProfile = new DelegateCommand(x => this.VM_ChangeMainWindow( new ViewModel.MainControlChangeEventArgs(typeof(View.CreateProfileUserControl), typeof(ViewModel.CreateProfileViewModel)))); this.Command_LoadActiveProfile = new DelegateCommand(x => this.Execut_LoadActiveProfile()); this.Command_ExportCardPack = new DelegateCommand(x => this.Execute_ExportCardPack()); this.Command_ImportCardPack = new DelegateCommand(x => this.Execute_ImportCardPack()); this.Command_StartNewQnA = new DelegateCommand(x => this.Execute_StartNewQnA()); this.Command_CreateNewQnA = new DelegateCommand(x => this.Execute_CreateNewQnA()); this.Command_StartMultiplayer = new DelegateCommand(x => this.Execute_StartMultiplayer()); this.Command_JoinMultiplayer = new DelegateCommand(x => this.Execute_JoinMultiplayer()); this.Command_Exit = new DelegateCommand(x => this.OnExit()); this.Command_Help = new DelegateCommand(x => this.Execute_Help()); this.mainContentViewModel.ChangeMainWindowContent += new ViewModel.Event_mainControlChange(VM_ChangeMainWindow); }