鼠标向上按钮应显示背景边框
我创造了一个简单的风格
<UserControl.Resources>
<Style TargetType="Button" x:Key="TransparentButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="Transparent">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
和按钮
<Button Height="20" Width="20" Padding="0,0,0,0" DockPanel.Dock="Top" Grid.Row="0" Grid.Column="1" Click="button_click" Style="{StaticResource TransparentButton}"
BorderBrush="Transparent" BorderThickness="0" Background="Transparent">
<Button.Content>
<Image Source="../Resources/Help_icon.png" Stretch="UniformToFill" />
</Button.Content>
</Button>
但在这种情况下,当按下按钮时,它不会显示在 UI 中。用户应该感觉到按钮被按下。
谢谢并恭祝安康