博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一个IMAGE BUTTON
阅读量:6914 次
发布时间:2019-06-27

本文共 1847 字,大约阅读时间需要 6 分钟。

<ControlTemplate x:Key="UserButton" TargetType="{x:Type Button}">

          <Grid>
               <Image x:Name="defaultimage" HorizontalAlignment="Stretch" Width="210" Height="55" Stretch="None" Source="b4.png"/>
               <Image x:Name="forcusimage" HorizontalAlignment="Stretch" Width="210" Height="55" Stretch="None" Panel.ZIndex="10" Source="b5.png" Visibility="Hidden"/>
               <TextBlock x:Name="text" Margin="0" TextWrapping="Wrap" Text="click button"  HorizontalAlignment="Center" Panel.ZIndex="100"/>
           </Grid>
           <ControlTemplate.Triggers>
               <Trigger Property="IsEnabled" Value="False">

               </Trigger>

           </ControlTemplate.Triggers>
       </ControlTemplate>
       <ControlTemplate x:Key="UserButton1" TargetType="{x:Type Button}">
           <Grid>
               <Image Name="img" Source="/b4.png"/>
               <!--TextBlock Name="text" Text="文字" HorizontalAlignment="Center" VerticalAlignment="Center"/-->
               <ContentPresenter  HorizontalAlignment="Center" VerticalAlignment="Center"/>
           </Grid>
           <ControlTemplate.Triggers>
               <Trigger Property="IsEnabled" Value="False">
                   <Setter TargetName="img" Property="Source" Value="/b5.png">
                   </Setter>
               </Trigger>
               <Trigger Property="IsMouseOver" Value="True">
                   <Setter TargetName="img" Property="Source" Value="/b6.png">
                   </Setter>
                   <Trigger.EnterActions>
                       <BeginStoryboard>
                           <Storyboard>
                               <DoubleAnimation Storyboard.TargetName="img" Storyboard.TargetProperty="Width" From="150" To="200" Duration="0:0:0.1" />
                           </Storyboard>
                       </BeginStoryboard>
                   </Trigger.EnterActions>
                   <Trigger.ExitActions>
                       <BeginStoryboard>
                           <Storyboard>
                               <DoubleAnimation Storyboard.TargetName="img" Storyboard.TargetProperty="Width" From="200" To="150" Duration="0:0:0.1" />
                           </Storyboard>
                       </BeginStoryboard>
                   </Trigger.ExitActions>
               </Trigger>
           </ControlTemplate.Triggers>
       </ControlTemplate>

//调用

<Button  Content="文字" Width="150" Tag="zoomout" ToolTip="放大" Template="{StaticResource  UserButton1}" />

转载于:https://www.cnblogs.com/qiujiahong/p/3316615.html

你可能感兴趣的文章
No goals have been specified for this build 解决方案
查看>>
netty深入学习之中的一个: 入门篇
查看>>
Gradle 1.12用户指南翻译——第三十六章. Sonar Runner 插件
查看>>
基于HTTP 协议认证介绍与实现
查看>>
(原創) 如何寫一個加法器? (C/C++) (SystemC) (IC Design)
查看>>
Npoi导入导出Excel操作
查看>>
说说接口封装
查看>>
TCP/IP建立连接与终止连接
查看>>
asp.net 中页面缓存 ,数据源缓存,自定义缓存
查看>>
[九度][何海涛] 翻转单词顺序
查看>>
微信相关的应用
查看>>
将数组适配到ListView
查看>>
Olivia Palermo & Johannes Huebl 模范情侣
查看>>
[geeksforgeeks] Convert a given Binary Tree to Doubly Linked List
查看>>
android mk详解
查看>>
程序员与禅的对话录
查看>>
【mysql】执行mysql脚本
查看>>
ASP.NET 时间方法大全
查看>>
git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支...
查看>>
scp 使用
查看>>