0
votes

I have WPF Menu in my application with sub-menu on some items, what I want to do is to change the border style and color of the sub-menu items on mouse over

bellow my snapshot [] I want to change the blue border style and color

Menu Item

1

1 Answers

-2
votes

You can use the following:

<Button Grid.Row="0" Width="100" Height="35" Content="Right-click me!" VerticalAlignment="Center" HorizontalAlignment="Center">
        <Button.ContextMenu>
            <ContextMenu>
                <ContextMenu.Resources>
                    <Style TargetType="{x:Type MenuItem}">
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver"  Value="True">
                                <Setter Property="Foreground" Value="#0264AD"></Setter>
                                <Setter Property="Background" Value="Yellow"></Setter>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </ContextMenu.Resources>
                <MenuItem Header="Menu item 1"/>
                <MenuItem Header="Menu item 2" />
                <Separator />
                <MenuItem Header="Menu item 3" />
            </ContextMenu>
        </Button.ContextMenu>
    </Button>

Just change the setters in the trigger to suit your needs.