我在界面上有几个按钮,我已经自定义了颜色。当我将鼠标悬停在它们上面时,它们会使用微软在Windows中使用的蓝色。它看起来很棒,只是没有我的颜色组合(黑色和金色)。
如何消除点击行为的突出显示?我需要为我的所有按钮执行此操作,这些按钮继承自基本样式:
<Style x:Key="ContentControlElementsStyle" TargetType="ContentControl">
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="Background" Value="Black"/>
<Setter Property="Foreground" Value="#F1B82D"/>
<Setter Property="BorderBrush" Value="#F1B82D"/>
</Style>
答案 0 :(得分:2)
使用以下按钮样式。
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}" >
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<!--<Trigger Property="Button.IsDefaulted" Value="True">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>-->
<!--<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="border" Value="#FFBEE6FD"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF3C7FB1"/>
</Trigger>-->
<!--<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="border" Value="#FFC4E5F6"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF2C628B"/>
</Trigger>-->
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter Property="Background" TargetName="border" Value="#FFBCDDEE"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF245A83"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="border" Value="#FFF4F4F4"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FFADB2B5"/>
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="#FF838383"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我评论了触发器,它会导致鼠标悬停和按下状态发生颜色变化。
答案 1 :(得分:1)
有些事情:
<Style.Triggers>
<Trigger Property="Button.IsPressed" Value="True">
<Setter Property="Content">
<Setter.Value>
<Image Source="MyAwesomeClickedPicture.png" Height="32" Width="32" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="Button.IsMouseOver" Value="True">
<Setter Property="Content">
<Setter.Value>
<Image Source="MyAwesomePicture.png" Height="32" Width="32" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
但在你的情况下,我猜你想要设置的颜色不是像我一样的颜色