We pay for user submitted tutorials and articles that we publish. Anyone can send in a contributionLearn More
How would you like your WPF application to have a Context Menu like this:
Well, It is not so hard. Here is how you do it:
This is the Context Menu that was defined for this example:
As you can see both the Context Menu and The MenuItem have styles, and this is where all the magic happens :).
The context menu style is very simple:
The real work is with the MenuItem Style. It is basically a ControlTemplate for the MenuItem where I use an Image and a TextBlock to design the Item.
Ok so here is the code. You can download the sample project to check it all out.
Some of you will as why is the Converter a Singleton, There is a good reason for that and I will explain it in a post later on.
If you have any questions please comment.
Update: Take alook at the better WPF Custom ContextMenu
Tags :BindingColorContext MenuControlTemplateConverterDisabledimageMenuItemSingletonStyleTemplateBindingTextBlock
Copyright © 2012 Dev102.com
Breeze : Designed by Amit Raz and Nitzan Kupererd