WPF圆角按钮与触发颜色变化
<Button x:Name="button1" Content="按钮1" Margin="10,10,0,0" Cursor="Pen">
<Button.Template>
<ControlTemplate>
<Border CornerRadius="15,15,15,15">
<Border.Background>
<SolidColorBrush x:Name="color2"></SolidColorBrush>
</Border.Background>
<Border.Triggers>
<EventTrigger RoutedEvent="Border.Loaded">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="color2" Storyboard.TargetProperty="(SolidColorBrush.Color)" From="AliceBlue" To="AntiqueWhite" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"></ColorAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button x:Name="button2" Content="按钮2" Margin="106,10,0,0" Opacity="0.5" BorderThickness="3" IsDefault="True" Click="button2_Click" Cursor="Wait" ToolTip="点击啊" HorizontalAlignment="Left"/>
<Button x:Name="button3" Content="开始分析" Margin="10,77,0,0" Click="button3_Click">
<Button.Template>
<ControlTemplate>
<Border BorderThickness="1" CornerRadius="16,16,16,16" >
<Border.Background>
<SolidColorBrush x:Name="ColorQ"/>
</Border.Background>
<Border.Triggers>
<EventTrigger RoutedEvent="Button.Loaded">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="ColorQ"
Storyboard.TargetProperty="(SolidColorBrush.Color)"
From="Red" To="Green" Duration="0:0:5"
AutoReverse="True" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
加上字体也变化:
<Button x:Name="button1" Margin="10,10,0,0" Cursor="Pen" ToolTip="点击按钮" Click="button1_Click" Background="White">
<Button.Template>
<ControlTemplate>
<Border CornerRadius="15,15,15,15">
<Label Content="点击分析" FontFamily="微软雅黑" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="12">
<Label.Foreground>
<SolidColorBrush x:Name="FontColor"></SolidColorBrush>
</Label.Foreground>
<Label.Triggers>
<EventTrigger RoutedEvent="Border.Loaded">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="FontColor" Storyboard.TargetProperty="(SolidColorBrush.Color)" From="#000000" To="#ffffff" Duration="0:0:10" AutoReverse="True" RepeatBehavior="Forever"></ColorAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Label.Triggers>
</Label>
<Border.Background>
<SolidColorBrush x:Name="color2"></SolidColorBrush>
</Border.Background>
<Border.Triggers>
<EventTrigger RoutedEvent="Border.Loaded">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="color2" Storyboard.TargetProperty="(SolidColorBrush.Color)" From="Red" To="purple" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"></ColorAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
看效果:


WPF圆角按钮与触发颜色变化的更多相关文章
- WPF圆角按钮例程
<Window x:Class="WpfApp3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/200 ...
- WPF圆角按钮
<ControlTemplate x:Key="CornerButton" TargetType="{x:Type Button}"> <Bo ...
- android 圆角按钮和按钮颜色
1. android 设置圆角按钮后,按下按钮后,还能改变按钮的颜色 <?xml version="1.0" encoding="UTF-8"?> ...
- UI设计篇·入门篇·绘制简单自定义矩形图/设置按钮按下弹起颜色变化/设置图形旋转
Android的基本控件和图形有限,难以满足所有的实际需要和设计需求,好在Android给出了相对完善的图形绘制和自定义控件的API,利用这些API,可以基本满足设计的需求. 自定义图像和控件的方法: ...
- android按钮被点击文字颜色变化效果
有的时候做应用需要点击按钮时文字颜色也跟着变,松开后又还原,目前发现两种解决方案:第一用图片,如果出现的地方比较多,那么图片的量就相当可观:第二,也就是本文讲到的.废话少说,先贴图片,再上代码. 正常 ...
- Qt 圆角按钮,面版自动布局
一.前言 在部分界面开发中,有时需要动态添加控件或按钮到面板中,在不需要时又需要删除该控件,故模仿视频开发中的设置屏蔽词,通过自己绘制的按钮与排布面板控件实现. 实现效果如下: 说明: 1.输入框可设 ...
- win10 uwp 圆角按钮
本文讲的是如何做圆角按钮,我们在UWP本来的按钮都是矩形,圆角Radius没有,所以本文就用简单方法去做圆角按钮. 我们按钮需要圆角,而自带没有,其实做一个很简单,把原来的按钮变为背景透明,然后使用矩 ...
- iOS中创建自定义的圆角按钮
iOS中很多时候都需要用到指定风格的圆角按钮,尽管UIButton提供了一个方式创建圆角按钮: + (id)buttonWithType:(UIButtonType)buttonType;//指定bu ...
- WPF 精修篇 获取系统颜色和字体样式
原文:WPF 精修篇 获取系统颜色和字体样式 看效果 <Grid> <Rectangle Fill="{DynamicResource {x:Static SystemCo ...
随机推荐
- Idea 无法显示mybatis-generator插件
Idea在pom.xml中添加了mybatis-generator插件后,右侧的maven projects中并未显示这个插件? 解决方法: 新建一个plugins标签和pluginManager同级 ...
- ASP.NET AJAX入门系列(9):在母版页中使用UpdatePanel
本文简单介绍一下在母版页中使用UpdatePanel控件,翻译自官方文档. 主要内容 1.添加UpdatePanel控件到Content Page 2.通过Master Page刷新UpdatePan ...
- EntityFrameworkCore操作记录
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design -Version 2.0.3 Add-Migration Init U ...
- pyhanlp用户自定义词典添加实例说明
pyhanlp用户自定义词典添加实例说明 pyhanlp是python版封装的的HanLP,项目地址:https://github.com/hankcs/pyhanlp 经过测试,HanLP比nltk ...
- HADOOP1.X中HDFS工作原理
转载自:http://www.daniubiji.cn/archives/596 HDFS(Hadoop Distributed File System )Hadoop分布式文件系统.是根据googl ...
- 阅读<All Digital VCXO Replacement for Gigabit Transceiver Applications>笔记(2)---XAPP589
阅读<All Digital VCXO Replacement for Gigabit Transceiver Applications>笔记(2)---XAPP589 1. 2. 3. ...
- Jenkins job 之间实现带参数触发
1 背景 开发打包的 jenkins job A 是在 local 的一台 windows 上,同时在这台 local 的 windows 上还有一 另一个 jenkins job B 是用来上传 j ...
- mass种子模块看完了
作者当然也不容易,要考虑各种兼容问题,要考虑效率问题(他真的考虑过吗,我表示强烈怀疑,貌似仅仅是风格上模仿其他源码) 相当无语. 本来我是知道的,代码 调试的过程中逐渐完善,逐渐与各种兼容问题和预想不 ...
- vagrant 安装笔记
本文档的编写参考慕课网视频教程,感谢慕课网提供的免费教程 http://www.imooc.com/learn/805 搭建一个环境,不需要重复配置,直接利用vagrant复制就可以了 https:/ ...
- VirtualBox 虚拟机复制
本文简单讲两种情况下的复制方式 1 跨电脑复制 2 同一virtrul box下 虚拟机复制 ---------------------------------------------- 1 跨电脑复 ...