WPF-Prism CanExecute method not being called

前端 未结 4 1338
南方客
南方客 2021-02-01 19:06

I am coding a simple login UserControl with two TextBoxes (Username and Password) and a Login button. I want the Login button to be enabled only when the username and password f

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 19:39

    Code for RaiseCanExecuteChanged:

        private void RaiseCanExecuteChanged()
        {
            DelegateCommand command = LoginCommand as DelegateCommand;
            command.RaiseCanExecuteChanged();
        }
    
        public const string UsernameProperty = "Username";
        private String _username;
        public String Username
        {
            get { return _username; }
            set
            {
                _username = value;
                this.NotifyPropertyChanged(UsernameProperty);
                RaiseCanExecuteChanged();
            }
        }
    
        

    提交回复
    热议问题