MenuItem blue on hover in xp, fine in windows 7

爷,独闯天下 提交于 2019-12-24 00:17:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!