如何在WPF中鼠标悬停删除按钮的辉光 [英] How to remove Glow of Button on Mouse hover in WPF
本文介绍了如何在WPF中鼠标悬停删除按钮的辉光的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用WPF中的一个简单的按钮。
我已经把图片为背景的按钮。
我的问题是,当我移动鼠标指针移动到按钮,它获得一个默认的光芒,并覆盖给出的背景图像。
I am using a simple button in WPF. I have put an image for the button on background. My problem is, when i move mouse pointer to button it get a default glow and override the image given as background.
<Button Grid.Column="3" Name="Play" BorderBrush="Transparent"
Focusable="False" Width="45" Height="45" Click="Play_Click"
VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,6,10,6">
<Button.Background >
<ImageBrush ImageSource="images/play.png" />
</Button.Background>
<Button.Foreground>
<ImageBrush ImageSource="images/play.png" />
</Button.Foreground>
</Button>
请帮我。
推荐答案
它在按钮的定义<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.controltemplate.aspx\">ControlTemplate.您应该创建自己的。
It's defined in Button's ControlTemplate. You should create your own.
例如这样的。
<Style x:Key="MyButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
然后就可以将此样式您的按钮。并设置背景你的那个形象。
Then you can apply this style to your Button. and set Background to that image of yours.
<Button Style="{StaticResource MyButtonStyle}" Grid.Column="3" Name="Play" BorderBrush="Transparent"
Focusable="False" Width="45" Height="45" Click="Play_Click"
VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,6,10,6">
<Button.Background >
<ImageBrush ImageSource="images/play.png" />
</Button.Background>
</Button>
这篇关于如何在WPF中鼠标悬停删除按钮的辉光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文