WPF ViewModel Commands CanExecute issue

后端 未结 5 764
情书的邮戳
情书的邮戳 2020-12-09 11:38

I\'m having some difficulty with Context Menu commands on my View Model.

I\'m implementing the ICommand interface for each command within the View Model, then creati

5条回答
  •  一生所求
    2020-12-09 12:21

    You have to keep track of when the status of CanExecute has changed and fire the ICommand.CanExecuteChanged event.

    Also, you might find that it doesn't always work, and in these cases a call to CommandManager.InvalidateRequerySuggested() is required to kick the command manager in the ass.

    If you find that this takes too long, check out the answer to this question.

提交回复
热议问题