1

A Control has its ContextMenu and its MenuItem is bound to an ICommand. ICommand's Can Execute has some code to enable and disable the MenuItem. This hits while loading and checks for Can Execute but it can hit while open the ContexMenu and it need to be hit(Checks) for each time while opening the ContextMenu.

<Border>
    <Border.ContextMenu> 
       <ContextMenu> 
           <MenuItem Command="{Binding SaveCommand, Source={StaticResource vm}}" CommandParameter="{Binding}" Header="Menu1" />
       </ContextMenu> 
    </Border.ContextMenu>
</Border>

How could be done this. Any idea?

Sankarann
  • 2,625
  • 4
  • 22
  • 59

1 Answers1

0

You should trigger the event ICommand.CanExecuteChanged() from ViewModel which shall cause the Control to invoke CanExecute from ViewModel.

ninja hedgehog
  • 405
  • 4
  • 16
  • This might be work but not in my case.. any generic way to achieve this? – Sankarann Aug 08 '13 at 06:00
  • There is some information missing here: when do you call the CanExecuteChanged? @Sankarann wants it to be evaluated when the contextmenu opens (and so do I). – RvdK Oct 29 '15 at 17:38