WPF Submenu styling?

Edit 1 Looking at your XAML, I think the issue is that you are styling ContextMenu but menus below that are of type Menu The first thing I'd try is to just change the TargetType attribute for the Style to Menu See if that gets applied at all levels. If not, I'd change it back and add another Style targeting Menu and see if that one gets applied to the submenu edit 2 Okay, I think I've got your answer. The submenu is actually a MenuItem which is obvious when looking at the XAML instead of the result.

The template and styling that you're setting on the ContextMenu must also be set on any MenuItem that is a submenu. I tried it out and created a style that targets MenuItem with a control template and trigger for IsMouseOver and it appeared to do what you're trying.

Typically, if you define as style in a "high" or "outer" element's Resources, and give it no key, it will apply to all items of the target type below. Are you doing this and seeing unexpected behaviour, or are you attempting to define/apply styles in-line at each level? Edit 1 Looking at your XAML, I think the issue is that you are styling ContextMenu, but menus below that are of type Menu.

The first thing I'd try is to just change the TargetType attribute for the Style to Menu. See if that gets applied at all levels. If not, I'd change it back and add another Style targeting Menu and see if that one gets applied to the submenu.

Edit 2 Okay, I think I've got your answer. The submenu is actually a MenuItem, which is obvious when looking at the XAML instead of the result. The template and styling that you're setting on the ContextMenu must also be set on any MenuItem that is a submenu.

I tried it out and created a style that targets MenuItem with a control template and trigger for IsMouseOver and it appeared to do what you're trying.

Check the edit for some code. Thanks Jay – user64718 Aug 2 '10 at 21:56 @mybrokengnome Updated answer in response to your edit. – Jay Aug 3 '10 at 0:40 Jay, that didn't fix anything, the sub-menu didn't take the style.

This is a very odd problem. – user64718 Aug 3 '10 at 1:07 @mybrokengnome Another update. – Jay Aug 3 '10 at 1:51 Jay, not really sure what you did to make yours work, but when I tried that it didn't do anything.

However, your post did help me find the right answer finally! I'll post the code in a new answer shortly, just cleaning it up some. – user64718 Aug 3 '10 at 2:50.

As promised, here's the code. Thanks for your help Jay, lead me in the right direction to finally find an answer on MSDN msdn.microsoft.com/en-us/library/ms75229... MenuItem and ContextMenu control the styling for the base menu, and the other two are for the submenu items. Jay's way may have worked, but I couldn't get it to unfortunately.

This works perfectly though, and probably allows for much more control over the submenus styling.

Thanks for posting it; don't forget to mark it as the answer. – Jay Aug 4 '10 at 1:53 @Jay, I still have 53 minutes till Stackoverflow lets me mark my own answer :-P – user64718 Aug 4 '10 at 20:11.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions