views:

7

answers:

0

I'm rehosting the MS WF 4 designer control in my application. I'm subscribing to the PreviewCanExecute handler for a given command. My event handler method is called. However, when I set the CanExecuteRoutedEventArgs.CanExecute property to false and CanExecuteRoutedEventArgs.Handled property to true, the context menu still appears enabled.

To make matters more confusing, when I try to replicate this behaviour in a sample WPF application (again rehosting the same MS WF 4 designer control), everything works as expected.

In my real application, I noted that I know my PreviewCanExecute handler is called. I know this because a breakpoint in this method is hit under the debugger. Further, setting the CanExecuteRoutedEventArgs.CanExecute property to false and CanExecuteRoutedEventArgs.Handled property to true does do something - it prevents the command from doing anything -- it's just that the context menu based on that command is still enabled (selecting the enabled menu item does not execute the command).

Any theories as to what may be happening? Complete details are available here.

Thank you!