xaml代码如下

<Button x:Class="UI.btn.ZButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:btn="clr-namespace:UI.btn"
d:DesignHeight="450" d:DesignWidth="800" Cursor="Hand">
<Button.Template>
<ControlTemplate TargetType="Button" >
<Grid ClipToBounds="True" Background="{TemplateBinding Background}" MouseLeftButtonDown="Grid_MouseLeftButtonDown" >
<Border>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" >
</ContentPresenter>
</Border>
<Path Fill="Black" x:Name="MyPath">
<Path.Data>
<EllipseGeometry x:Name="MyEllip" Center="{Binding MyProperty}" RadiusX="0" RadiusY="{Binding RelativeSource={RelativeSource Mode=Self},Path=RadiusX}">
</EllipseGeometry>
</Path.Data>
</Path>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>

CS代码

private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var target=Template.FindName("MyEllip", this) as EllipseGeometry;
target.Center = Mouse.GetPosition(this);
var animation = new DoubleAnimation()
{
From=0,
To=150,
Duration=new Duration(TimeSpan.FromSeconds(1))
};
target.BeginAnimation(EllipseGeometry.RadiusXProperty, animation);
var animation2 = new DoubleAnimation()
{
From = 0.3,
To = 0,
Duration = new Duration(TimeSpan.FromSeconds(1))
};
var target2= Template.FindName("MyPath",this) as Path;
target2.BeginAnimation(Path.OpacityProperty, animation2);
}

最新文章

  1. eclipse maven update error 解决方法
  2. 运行 Spark on YARN
  3. Java学习笔记 第一章 入门&lt;转&gt;
  4. 【kd-tree】bzoj4154 [Ipsc2015]Generating Synergy
  5. javascript,HTML,PHP,ASP做301跳转代码 SEO优化设置
  6. Eclipse+SVN搭建开发环境
  7. form表单验证2
  8. springmvc 注解 RequestParam/RequestHeader/CookieValue
  9. Mingyang.net:如何获取所有的请求参数?
  10. [转]流媒体协议介绍(rtp/rtcp/rtsp/rtmp/mms/hls)
  11. linux时间无法同步的解决方案
  12. linux下如何编译python生成libpython2.5.so动态库
  13. 操作PDF文档功能的相关开源项目探索——iTextSharp 和PDFBox
  14. Juuluu 旗下企业站点管理系统3.0.1公布!
  15. (Relax 数论1.6)POJ 1061 青蛙的约会(扩展的欧几里得公式)
  16. 北京联通100M光纤宽带需邀请函 实际速率12MB/S - OFweek光通讯网
  17. 老司机实战Windows Server Docker:3 单节点Windows Docker服务器简单运维(上)
  18. 读Zepto源码之Data模块
  19. java(MyEclipse)创建webservice和测试webservice
  20. 通过flask的request对象获取url

热门文章

  1. redis为什么那么快?
  2. webpack(6)webpack处理图片
  3. 通过ajax方式在界面上加载loading状态(仅作记录)
  4. linux添加用户并授权访问目录
  5. adb 记录ADB执行记录
  6. sql2008编辑前200行怎么修改
  7. SpringBoot 整合 MybatisPlus 3.0
  8. [刘阳Java]_Spring AOP基于XML配置介绍_第9讲
  9. 前端开发入门到进阶第一集【使用sublime快速编写Html和Css】
  10. Java成长之路--一个非科班生的进阶之路