コード例 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var mainWindowState = new MainWindowState();

            new MainWindow
            {
                DataContext = new MainWindowViewModel(mainWindowState)
            }.Show();
        }
コード例 #2
0
        public MainWindowViewModel(MainWindowState state)
        {
            _state = state;

            var stateListener = new PropertyChangedEventListener(_state);

            stateListener.RegisterHandler(nameof(_state.Mode), (_, __) => RaisePropertyChanged(nameof(Mode)));
            CompositeDisposable.Add(stateListener);

            UserScreenCommand    = new ViewModelCommand(() => _state.Mode = MainWindowMode.User);
            ProductScreenCommand = new ViewModelCommand(() => _state.Mode = MainWindowMode.Product);
        }