示例#1
0
        private void SetWindowCommands(MainVM vm)
        {
            if (vm.CloseAction == null)
            {
                vm.CloseAction = new Action(() => this.Close());
            }

            if (vm.MaximizeAction == null)
            {
                vm.MaximizeAction = new Action(() =>
                {
                    if (this.WindowState == WindowState.Maximized)
                    {
                        this.WindowState = WindowState.Normal;
                    }
                    else if (this.WindowState == WindowState.Normal)
                    {
                        this.WindowState = WindowState.Maximized;
                    }
                });
            }

            if (vm.MinimizeAction == null)
            {
                vm.MinimizeAction = new Action(() => this.WindowState = WindowState.Minimized);
            }

            if (vm.DragAction == null)
            {
                vm.DragAction = new Action(() => this.DragMove());
            }
        }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();

            MainVM vm = new MainVM();

            DataContext = vm;

            SetWindowCommands(vm);
        }