Answer the question
In order to leave comments, you need to log in
How to change Foreground MenuItem on mouse hover?
Help me please. Can't make text color change (ForeGroung) for MenuItem "Settings".
<Window.Resources>
<Style TargetType="MenuItem">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
<ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
<Grid>
<Border Height="25" Width="80" Name="Head">
<ContentPresenter ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Popup Name="Popup" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" PopupAnimation="Fade">
<StackPanel IsItemsHost="True" Background="#01FFFFFF" Focusable="True"/>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="Head" Property="Background" Value="#3500ACFF"/>
<Setter TargetName="Head" Property="BorderBrush" Value="#FF00ACFF"/>
<Setter TargetName="Head" Property="BorderThickness" Value="1,1,1,1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Window.Resources>
<Grid>
<Menu VerticalAlignment="Top" Background="Transparent">
<MenuItem Name="Setting" Header="Настройки" Foreground="Lime">
<MenuItem Header="Свойства"/>
<MenuItem Header="О программе"/>
<MenuItem Header="Выход"/>
</MenuItem>
</Menu>
</Grid>
Answer the question
In order to leave comments, you need to log in
Common mistake
<MenuItem Name="Setting" Header="Настройки">
<MenuItem.Style>
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Foreground" Value="Lime"></Setter>
</Style>
</MenuItem.Style>
<MenuItem Header="Свойства"/>
<MenuItem Header="О программе"/>
<MenuItem Header="Выход"/>
</MenuItem>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question