Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Ribbon - ButtonTool and CanExecute
posted

Hi

I'm using NetAdvantage_Silverlight_2010 Vol.3

i'm trying to bind ButtonTool.Commands to my command, This command binding work correct and command CanExecute and Execute work perfect but result of CanExecute method not effect on  ButtonTool to Enable or disabling it.

what is problem?

Thanks

 

 

 

Parents
No Data
Reply
  • 6475
    Verified Answer
    posted

    Hi,

    In order for the control to be disabled or enabled, you need to notify the Commanding Framework that CanExecute has changed for your custom command, so the associated controls can then call the CanExecute() method off the CommandSource and update their IsEnabled state accordingly.

    In order to do that, you'll need to call a static method of the CommandSourceManager class:

    CommandSourceManager.NotifyCanExecuteChanged(typeof(MyCustomCommand));

     

    I've attached a sample that demostrates that. In the attached sample, the static method is called in the setter of CanExecuteCommandFlag, so when the value of the flag changes, the ButtonTool can automatically update its state.

     

    Hope that helps,

    SampleApp1.zip
Children