且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在打开上下文菜单时提高上下文菜单命令的CanExcute

更新时间:2023-11-30 21:37:16

BaseCommand 中,将 CanExecuteChanged 替换为以下内容。

Inside BaseCommand, replace the CanExecuteChanged to look like the following. And it will work the way you want it.

   public event EventHandler CanExecuteChanged
    {
        add
        {
            CommandManager.RequerySuggested += value;
        }
        remove
        {
            CommandManager.RequerySuggested -= value;
        }
    }