在 XP 中鼠标悬停时菜单项呈蓝色,在 Windows 7 中则正常
使用 XAML,我们在应用程序的右下角创建了一系列按钮。它们位于 DockPanel 中,而 DockPanel 位于 Grid 中。它们只是用作切换按钮,单击时它会更改为其他图像。当您将鼠标悬停在 XP 中的按钮上时,就会出现问题,按钮完全变成蓝色,您看不到图像......只是蓝色。这在 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=""/>
需要注意的一件事是,我们在同一个 DockPanel 中还有另一个按钮,它本身具有单击时填充的菜单项,当悬停在 xp 和 7 上时工作正常...这是代码:
<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>
我尝试将 SystemColors.HighlightBrushKey 设置为透明,但这只会使图像完全消失。
你知道为什么这在 XP 上不起作用但在 7 上却可以吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此行为与 Win7 和 XP 上的不同样式相关。
作为解决方案,您需要添加 Aero 样式。
This behavior is associated with different styles on Win7 and XP.
As a solution, you need to add Aero styles.