public void Initialize() { var view = new MainWindow(); mViewModel = new MainWindowViewModel() { StartCommand = new RelayCommand(ExecuteStartCommand), CostMonthCommand = new RelayCommand(ExecuteCostMonthCommand), CostUnitCommand = new RelayCommand(ExecuteCostUnitCommand), VehiclesCommand = new RelayCommand(ExecuteVehiclesCommand), EmployeesCommand = new RelayCommand(ExecuteEmployeesCommand), UnitsCommand = new RelayCommand(ExecuteUnitsCommand), UsersCommand = new RelayCommand(ExecuteUsersCommand), NewItemCommand = new RelayCommand(ExecuteNewItemCommand), SaveItemCommand = new RelayCommand(ExecuteSaveItemCommand), DeleteItemCommand = new RelayCommand(ExecuteDeleteItemCommand) }; mViewModel.Visibility = Visibility.Hidden; if (CurrentUser.isAdmin) { mViewModel.Visibility = Visibility.Visible; } view.DataContext = mViewModel; startControlController = new StartControlController(); mViewModel.ActiveViewModel = startControlController.Initialize(); startControlViewModel = (StartControlViewModel)mViewModel.ActiveViewModel; view.Show(); }
public override ViewModelBase Initialize() { mViewModel = new StartControlViewModel() { ChangePasswordCommand = new RelayCommand(ExecuteChangePasswordCommand) }; return(mViewModel); }
public void ExecuteStartCommand(object obj) { startControlController = new StartControlController(); mViewModel.ActiveViewModel = startControlController.Initialize(); startControlViewModel = (StartControlViewModel)mViewModel.ActiveViewModel; startControlController.CurrentUser = CurrentUser; mViewModel.ButtonsEnabled = false; mViewModel.StartCurrentBackColor = new SolidColorBrush(Colors.DodgerBlue); mViewModel.StartCurrentForeColor = new SolidColorBrush(Colors.White); mViewModel.CostMonthCurrentBackColor = new SolidColorBrush(Colors.White); mViewModel.CostMonthCurrentForeColor = new SolidColorBrush(Colors.Black); mViewModel.CostBusinessUnitCurrentBackColor = new SolidColorBrush(Colors.White); mViewModel.CostBusinessUnitCurrentForeColor = new SolidColorBrush(Colors.Black); mViewModel.VehiclesCurrentBackColor = new SolidColorBrush(Colors.White); mViewModel.VehiclesCurrentForeColor = new SolidColorBrush(Colors.Black); mViewModel.EmployeeCurrentBackColor = new SolidColorBrush(Colors.White); mViewModel.EmployeeCurrentForeColor = new SolidColorBrush(Colors.Black); mViewModel.BusinessUnitCurrentBackColor = new SolidColorBrush(Colors.White); mViewModel.BusinessUnitCurrentForeColor = new SolidColorBrush(Colors.Black); mViewModel.UserCurrentBackColor = new SolidColorBrush(Colors.White); mViewModel.UserCurrentForeColor = new SolidColorBrush(Colors.Black); }
/// <summary> /// 選択中のアイテムが変更された時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnSelectedItemChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName != "SelectedItem") { return; } PathBar.OnSelectedItemChanged(sender, e); //ContentViewModel = null; //選択されたコンテンツに対応するVMを設定する //switch-case文ではcaseに定数値以外を設定できないため、if文で実装する if (SelectedItem.ContentName == "コンテンツ") { ContentViewModel = new StartControlViewModel(); } else if (SelectedItem.ContentName == Strings.ContentName_CustomControl) { ContentViewModel = new CustomControlViewModel(); } else if (SelectedItem.ContentName == Strings.ContentName_ProgressBar) { ContentViewModel = new ProgressBarViewModel(); } else if (SelectedItem.ContentName == Strings.ContentName_KeyboardNavigation) { ContentViewModel = new KeyboardNavigationViewModel(); } else if (SelectedItem.ContentName == Strings.ContentName_DragDropControl) { ContentViewModel = new DragDropControlViewModel(); } else { //未実装コンテンツ用のVMを設定 ContentViewModel = new NotImplementationViewModel(); } }
public StartControl(object dialogIdentifier) { InitializeComponent(); DataContext = new StartControlViewModel(dialogIdentifier); }