我发现了有关将按钮边框设置为透明的主题。
这工作正常,但我想将其用于按钮背景而不是边框。
我放入的链接中的解决方案<Window.Resources>...</Window.Resources>
:
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="Green"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
Source: 如何在 WPF 中更改按钮 MouseOver 的背景? https://stackoverflow.com/questions/17259280/mouseover-button-background
如何编辑此代码,以便我可以使用它将按钮的背景设置为透明而不是其边框?
试试这个透明按钮的片段:
<Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0">
<-- PUT BUTTON CONTENT HERE e.g. a Image -->
</Button>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)