tags:

views:

41

answers:

2

I'm using WPF Menu. I have about 20 different menu buttons and in my XAML code I associate a Click event to each menu item.

Is this the preferred way?

A: 

Well, you can certainly do it this way, or you can use commands instead. See e.g. this tutorial.

Dmitri Nesteruk
Thanks for the link. I don't really see how this is better than having 20 Click events in a #Region. Can you let me know why I should use this approach? It seems to give out uglier XAML markup.
Sergio Tapia
Well, truth be told, it only makes sense if at a later stage you decide that some of the same commands need to be fired off by, say, a toolbar. It seems to be the *a la mode* way of doing it in WPF.
Dmitri Nesteruk
A: 

Commands are preferred, more easy, more decoupled (see the Dmitri tutorial). Another solution is to use a single event handler for all menus in which you have a switch to choose which part should be executed.

ema