MouseOver Trigger firing on ContextMenu with overridden ControlTemplate. Where is it coming from?

Posted by Dabblernl on Stack Overflow See other posts from Stack Overflow or by Dabblernl
Published on 2010-03-07T19:30:28Z Indexed on 2010/03/08 14:36 UTC
Read the original article Hit count: 388

Filed under:
|
|

I have this very simple ControlTemplate:

<ControlTemplate TargetType="{x:Type ContextMenu}">
                    <Border 
                           Name="Border"
                           Background="{StaticResource BlueBackground}"
                           BorderBrush="LightBlue"
                           CornerRadius="10"
                           BorderThickness="1" >
                        <StackPanel IsItemsHost="True"/>
                    </Border>
                </ControlTemplate>

I made it to create a nifty jawdroppingly beautiful rounded corner! However, when I point the mouse over a contextmenu a MouseOver Trigger fires from somewhere that draws a terribly ugly nearly square border on top of my nifty rounded border!

Where is it coming from??

EDIT: The most likely cause is that the ContextMenu is an ItemsControl that holds MenuItems, even when my ContextMenu holds a single UserControl. So the UserControl is seen as a MenuItem and highlighted when the IsMouseOver==true! What is the easiest way to disable this behaviour?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about controltemplate