コード例 #1
0
        private bool _windowClosedBySelf = false; // Tracks whether the window was closed by logic internal
                                                  // to the command (e.g. not by clicking the window's close button)
        // Presents the user with a sign-in dialog
        public override void Execute(object parameter)
        {
            // Initialize the viewmodel if not yet done
            if (viewModel == null)
            {
                // Instantiate the viewmodel and sign-in/cancel commands
                viewModel = new SignInViewModel();
                DelegateCommand signInCommand = new DelegateCommand(onSignIn, canSignIn);
                viewModel.SignIn = signInCommand;
                viewModel.Cancel = new DelegateCommand(onCancel);

                // When a property changes on the viewmodel, have the sign-in command check its executable state
                viewModel.PropertyChanged += (o, e) => signInCommand.RaiseCanExecuteChanged();

                // instantiate the view
                view = new SignInView() { Margin = new Thickness(10) };

                // plug the viewmodel into the view
                view.DataContext = viewModel;
            }

            // Prompt for sign-in
            if (MapApplication.Current != null)
                MapApplication.Current.ShowWindow(Strings.SignIn, view, true, null, onWindowClosed,
                    WindowType.DesignTimeFloating);
        }
コード例 #2
0
        private bool _windowClosedBySelf    = false; // Tracks whether the window was closed by logic internal
                                                     // to the command (e.g. not by clicking the window's close button)
        // Presents the user with a sign-in dialog
        public override void Execute(object parameter)
        {
            // Initialize the viewmodel if not yet done
            if (viewModel == null)
            {
                // Instantiate the viewmodel and sign-in/cancel commands
                viewModel = new SignInViewModel();
                DelegateCommand signInCommand = new DelegateCommand(onSignIn, canSignIn);
                viewModel.SignIn = signInCommand;
                viewModel.Cancel = new DelegateCommand(onCancel);

                // When a property changes on the viewmodel, have the sign-in command check its executable state
                viewModel.PropertyChanged += (o, e) => signInCommand.RaiseCanExecuteChanged();

                // instantiate the view
                view = new SignInView()
                {
                    Margin = new Thickness(10)
                };

                // plug the viewmodel into the view
                view.DataContext = viewModel;
            }

            // Prompt for sign-in
            if (MapApplication.Current != null)
            {
                MapApplication.Current.ShowWindow(Strings.SignIn, view, true, null, onWindowClosed,
                                                  WindowType.DesignTimeFloating);
            }
        }