WPF CommandParameter binding not updating

前端 未结 1 1666
终归单人心
终归单人心 2020-12-17 00:10

I am trying to use Command and CommandParameter binding with Buttons in a WPF application. I have this exact same code working just fine in Silverlight so I am wondering wha

相关标签:
1条回答
  • 2020-12-17 00:38

    You need to tell WPF that CanExecute can change - you can do this automatically in your TestCommand class like this:

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

    WPF will then ask CanExecute everytime a property changes in the view.

    0 讨论(0)
提交回复
热议问题