我有两个png图像,经过三重检查以确保它们正确透明。这是按钮样式代码:
<Window.Resources>
<Style x:Key="TrackingButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Style.Triggers>
<!--Default Base-->
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Content">
<Setter.Value>
<Image Source="Resources/Start_Base.png"/>
</Setter.Value>
</Setter>
</Trigger>
<!--Hover-->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Content">
<Setter.Value>
<Image Source="Resources/Start_Hover.png"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
<!--Default Style-->
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="Transparent"/>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="Transparent"/>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</Window.Resources>
这是按钮的默认状态:DefaultState 但是当鼠标悬停在该按钮上时,该按钮将失去透明性,并且在应该透明的区域周围出现白色边框:HoveredOver
我不确定这是怎么回事。
答案 0 :(得分:0)
如果您想摆脱Chrome,可以定义自己的自定义ControlTemplate
:
<Style x:Key="TrackingButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Image x:Name="img" Source="Resources/Start_Base.png"/>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="img" Property="Source" Value="Resources/Start_Hover.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>