WPF - Command in MenuItem in DataTemplate

I have a DataTemplate containing an image. For the image, I added a ContextMenu with a MenuItem. To MenuItem I have linked a command. Then I process the command in the view using the DataTemplate.

In the CanExecute handler, I have e.CanExecute = true. But the Executed handler is never executed. If I remove the assignment of the MenuItem command, the menu is shown correctly when I right clicked on the image.

What am I doing wrong?

Thanks!

-2


a source to share


1 answer


I figured it out - after e.CanExecute = true; I had a MessageBox.Show and it was getting in the way of calling Executed. However, I don't know why.



0


a source







All Articles