c# - MSFT RibbonCommand.CanExecute not firing when called manually -


imagine following command usage:

    var command = new ribboncommand(name, typeof(ribboncommand));     command.canexecute += command_canexecute;     command.executed += command_executed;      void command_executed(object sender, executedroutedeventargs e)     {         //has check again actual conditions due rc specifics         if (e.command.canexecute(null))         {             ...         }     }      void command_canexecute(object sender, canexecuteroutedeventargs e)     {         return true;     } 

the problem e.command.canexecute(null) return false , debugger not breaking on canexecute method not being fired @ all. though through debug see e.command contains correct command correct canexecute method defined.

the strangest thing mates has same code (from common repository) working fine! difference can see use win7 os , use win8.1. tried reboot, cleanup , stuff no luck. ideas going on?

ps: command_canexecute() fires correctly ui control attached. use microsoft.windows.controls.ribbon.ribboncommand not smth 3rd party.

also i've found ribboncommand based on routedcommand following notable code. may there specifics:

    public event executedroutedeventhandler executed     {         add         {             if (_commandbinding == null)             {                 _commandbinding = new commandbinding(this, value, _canexecute);                 commandmanager.registerclasscommandbinding(typeof(mainwindow), _commandbinding);             }             else             {                 _commandbinding.executed -= value;                 _commandbinding.executed += value;             }             _executed = value;         }         remove         {             if (_commandbinding != null)                 _commandbinding.executed -= value;             _executed = null;         }     }      public event canexecuteroutedeventhandler canexecute     {         add         {             if (_commandbinding == null)             {                 _commandbinding = new commandbinding(this, _executed, value);                 commandmanager.registerclasscommandbinding(typeof(mainwindow), _commandbinding);             }             else             {                 _commandbinding.canexecute -= value;                 _commandbinding.canexecute += value;             }             _canexecute = value;         }         remove         {             if (_commandbinding != null)                 _commandbinding.canexecute -= value;             _canexecute = null;         }     } 


Comments