How to disable MouseOver effects on a Button in WPF( 如何取消默认按钮的鼠标悬停效果)
Posted on 2013-03-18 15:49 Mike Song 阅读(1091) 评论(1) 收藏 举报参考文章: http://stackoverflow.com/questions/1224439/how-do-you-disable-mouseover-effects-on-a-button-in-wpf
我这个小项目需要取消悬停效果和点击效果, 自己稍作改动如下:
取消 IsMouseOver, 只需要删掉那部分代码就可以了.
<Style TargetType="{x:Type Button}"> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Name="Border" Background="{TemplateBinding Control.Background}" Focusable="False" BorderThickness="1" BorderBrush="#FF707070"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding ContentControl.Content}" /> </Border> <ControlTemplate.Triggers> <!--<Trigger Property="IsMouseOver" Value="true"> <Setter TargetName="Border" Property="Background" Value="#808080" /> </Trigger>--> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="Border" Property="Background" Value="Silver" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
浙公网安备 33010602011771号