问题
Using XAML we've created a series of buttons at the bottom right of our application. They are in a DockPanel, which is in a Grid. They're just used as toggles, when clicked it changes to the other image. The problem occurs when you hover over the button in XP, the button completely turns to blue, you can't see the image...just blue. This works fine in win 7...
<MenuItem Name="PhonePad_MenuItem" Background="{DynamicResource Audio_Btn_Dialer_Disabled_Brush}" Height="22" Width="22" Click="PhonePad_MenuItem_Click" Margin="0,1,0,0" IsEnabled="False" ToolTip=""/>
One thing to note is that we have another button in the same DockPanel, which itself has menu items which are populated when clicked, works fine when hovered on both xp and 7...here's the code:
<MenuItem Name="Settings_MenuItem" Height="20" Width="Auto" IsEnabled="False" SubmenuOpened="Settings_MenuItem_SubmenuOpened" ToolTip="">
<MenuItem.Header>
<DockPanel Height="Auto" Width="Auto">
<Image Name="Settings_MenuItem_Back" Source="{DynamicResource Audio_Btn_Device_Settings_Disabled}" Height="22" Width="22" HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="True" />
</DockPanel>
</MenuItem.Header>
<MenuItem Header="" />
</MenuItem>
I tried setting the SystemColors.HighlightBrushKey
to transparent but that just makes the image disappear altogether.
Any ideas why this wouldn't work on XP but is fine on 7?
回答1:
This behavior is associated with different styles on Win7 and XP. As a solution, you need to add Aero styles.
<ResourceDictionary Source="/PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml"
来源:https://stackoverflow.com/questions/8139221/menuitem-blue-on-hover-in-xp-fine-in-windows-7