WPF Button 样式 鼠标移入发光
来源:互联网 发布:怎么查路由器端口号 编辑:程序博客网 时间:2024/05/21 10:34
<Style TargetType="Button"> <Setter Property="Foreground" Value="Black"></Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <!--背景色--> <Border x:Name="back" Opacity="0.8" CornerRadius="3"> <Border.BitmapEffect> <OuterGlowBitmapEffect Opacity="1" GlowSize="0" GlowColor="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(Button.Background).(SolidColorBrush.Color)}"/> </Border.BitmapEffect> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1.5"> <GradientBrush.GradientStops> <GradientStopCollection> <GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0"/> <GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0.4"/> <GradientStop Color="#FFF" Offset="1"/> </GradientStopCollection> </GradientBrush.GradientStops> </LinearGradientBrush> </Border.Background> <!--前景色及边框--> <Border x:Name="fore" BorderThickness="1" CornerRadius="3" BorderBrush="#5555"> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientBrush.GradientStops> <GradientStopCollection> <GradientStop Color="#6FFF" Offset="0.5"/> <GradientStop Color="#1111" Offset="0.51"/> </GradientStopCollection> </GradientBrush.GradientStops> </LinearGradientBrush> </Border.Background> <!--按钮内容--> <ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}"> <ContentPresenter.BitmapEffect> <DropShadowBitmapEffect Color="#000" Direction="-90" ShadowDepth="2" Softness="0.1" Opacity="0.3" /> </ContentPresenter.BitmapEffect> </ContentPresenter> </Border> </Border> <!--触发器--> <ControlTemplate.Triggers> <!--鼠标移入移出--> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation To="10" Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" /> <ColorAnimation To="#AFFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" /> <ColorAnimation To="#3FFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" /> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" /> <ColorAnimation Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" /> <ColorAnimation Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" /> </Storyboard> </BeginStoryboard> </Trigger.ExitActions> <!--<Setter TargetName="back" Property="Background"> <Setter.Value> <RadialGradientBrush GradientOrigin="0.496,1.052"> <RadialGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.5" ScaleY="1.5"/> <TranslateTransform X="0.02" Y="0.3"/> </TransformGroup> </RadialGradientBrush.RelativeTransform> <GradientStop Offset="1" Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}"/> <GradientStop Offset="0.45" Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)}"/> </RadialGradientBrush> </Setter.Value> </Setter>--> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
以 上是XAML文件的样式
以下是效果图:
鼠标移入
0 0
- WPF Button 样式 鼠标移入发光
- WPF Button 鼠标移入、移除、选中状态的改变
- WPF Button 鼠标移动改变样式
- WPF ScrollViewer 滚动条鼠标移入移出及鼠标按下拖动时的外观样式
- 鼠标移入移出改变样式
- 【WPF】样式与模板:鼠标移入/悬浮时按钮的背景色不改变
- demo5,鼠标移入移出改变样式,总结
- 简单的鼠标移出移入样式改变
- Wpf Button样式例子
- BUTTON WPF 样式
- wpf button 样式模版
- WPF Silverlight Button样式
- Wpf Button自定义样式
- wpf中button样式定义
- hover事件1,鼠标移入改变css样式
- 鼠标移入移出,样式修改,显示隐藏提示消息
- 【WPF】给Button一个LinkLabel的样式
- ExpressionBlend教程:WPF Button自定义样式
- ASP.NET MVC 部分视图
- Python中线程池的实现(三)
- http协议中get和post方法的优点和缺点
- 下载The Swift Programming Language.mobi版
- 总结—每个程序员都应该了解的固态硬盘知识
- WPF Button 样式 鼠标移入发光
- 设计模式学习03—抽象工厂模式
- 2014WWDC发布会的解读
- chrome查看手机版网页
- 100%托管代码自定义服务器控件ASP.NET Barcode Web Server Control
- HTTP hijack
- 在android 中利用button 按钮设置监听事件
- Java创建线程的两个方法
- 大数相加问题