/// <summary> /// コンストラクタ /// </summary> /// <param name="regionManager"></param> public MainWindowViewModel(IRegionManager regionManager) { RegionManager = regionManager; /***** ページの初期表示 *****/ _ = RegionManager.RegisterViewWithRegion("ContentRegion", typeof(Views.Page1)); /***** 変数Pageの数値でボタンの有効/無効を切り替える *****/ Page1View = Page.Select(p => p != 1).ToReactiveCommand(); Page2View = Page.Select(p => p != 2).ToReactiveCommand(); /***** ページを表示する2つのパターン *****/ _ = Page1View.Subscribe(_ => { RegionManager.RequestNavigate("ContentRegion", nameof(Views.Page1)); Page.Value = 1; }).AddTo(Disposable); //_ = Page1View.Subscribe(SetPage1).AddTo(Disposable); _ = Page2View.Subscribe(_ => { RegionManager.RequestNavigate("ContentRegion", nameof(Views.Page2)); Page.Value = 2; }).AddTo(Disposable); //_ = Page2View.Subscribe(SetPage2).AddTo(Disposable); _ = ClosedCommand.Subscribe(Close).AddTo(Disposable); }
/// <summary> /// Default constructor /// </summary> /// <param name="window"></param> public WindowViewModel(Window window) { mWindow = window; // Listen out for the window resizing mWindow.StateChanged += (sender, e) => { //Fire off events for all properties that are affected by a resize OnPropertyChanged(nameof(ResizeBorderThickness)); OnPropertyChanged(nameof(OuterMarginSize)); OnPropertyChanged(nameof(OuterMarginSizeThickness)); OnPropertyChanged(nameof(WindowRadius)); OnPropertyChanged(nameof(WindowCornerRadius)); }; //Create commands MinimizeCommand = new RelayCommand(() => mWindow.WindowState = WindowState.Minimized); MaximizeCommand = new RelayCommand(() => mWindow.WindowState ^= WindowState.Maximized); CloseCommand = new RelayCommand(() => mWindow.Close()); MenuCommand = new RelayCommand(() => SystemCommands.ShowSystemMenu(mWindow, GetMousePosition())); //Assign the content CurrentPage = new Page1View(); //CurrentPage = new FileSelectorView(); }