WPF圆角按钮例程
<Window x:Class="WpfApp3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp3"
mc:Ignorable="d"
Title="我的例程" Height="450" Width="800" Background="Black">
<Window.Resources> <Style TargetType="Button" >
<Setter Property="Template"> <Setter.Value>
<ControlTemplate TargetType="Button" >
<Border x:Name="border" Background="SkyBlue"
CornerRadius="10" Height="30" BorderBrush="Black" BorderThickness="0" SnapsToDevicePixels="True">
<Border.Effect>
<DropShadowEffect Color="Black" Direction="0" ShadowDepth="1" Opacity="1" />
</Border.Effect>
<TextBlock Text="{TemplateBinding Content}"
VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="16" FontFamily="黑体">
<TextBlock.Effect>
<DropShadowEffect Color="Black" Direction="0" ShadowDepth="1" Opacity="1" />
</TextBlock.Effect>
</TextBlock>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="LightBlue" TargetName="border"></Setter>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" Value="SkyBlue" TargetName="border"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter> </Style>
</Window.Resources>
<Grid Background="Brown" >
<Button Content="暂停" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="445,344,0,0"></Button>
<Button Content="添加" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="100,344,0,0"></Button>
<Button Content="播放" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="219,344,0,0"></Button>
<Button Content="开始" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="327,344,0,0" ></Button>
</Grid>
</Window>
这段代码直接使用VS全部粘贴就能够使用。分别演示了圆角,变色,阴影。 需要注意的是因为没有给style输入名字,导致所有的按钮都会被重画。
WPF圆角按钮例程的更多相关文章
- WPF圆角按钮与触发颜色变化
<Button x:Name="button1" Content="按钮1" Margin="10,10,0,0" Cursor=&q ...
- WPF圆角按钮
<ControlTemplate x:Key="CornerButton" TargetType="{x:Type Button}"> <Bo ...
- android 圆角按钮和按钮颜色
1. android 设置圆角按钮后,按下按钮后,还能改变按钮的颜色 <?xml version="1.0" encoding="UTF-8"?> ...
- win10 uwp 圆角按钮
本文讲的是如何做圆角按钮,我们在UWP本来的按钮都是矩形,圆角Radius没有,所以本文就用简单方法去做圆角按钮. 我们按钮需要圆角,而自带没有,其实做一个很简单,把原来的按钮变为背景透明,然后使用矩 ...
- WPF解决按钮上被透明控件遮盖时无法点击问题
原文:WPF解决按钮上被透明控件遮盖时无法点击问题 IsHitTestVisible="False" 在控件上设置如上属性即可,即可让透明控件不触发点击效果
- iOS中创建自定义的圆角按钮
iOS中很多时候都需要用到指定风格的圆角按钮,尽管UIButton提供了一个方式创建圆角按钮: + (id)buttonWithType:(UIButtonType)buttonType;//指定bu ...
- WPF 圆角textbox
原文:WPF 圆角textbox 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/a771948524/article/details/9245965 ...
- [C# WPF] 根据按钮动态跳转窗体
WPF 根据按钮动态跳转窗体 XMAL文件中,用Tag保存要跳的页面 <Button Name="btnWindow01" Content="ClickMe&quo ...
- Qt 圆角按钮,面版自动布局
一.前言 在部分界面开发中,有时需要动态添加控件或按钮到面板中,在不需要时又需要删除该控件,故模仿视频开发中的设置屏蔽词,通过自己绘制的按钮与排布面板控件实现. 实现效果如下: 说明: 1.输入框可设 ...
随机推荐
- serde
一.背景 1.当进程在进行远程通信时,彼此可以发送各种类型的数据,无论是什么类型的数据都会以二进制序列的形式在网络上传送. 发送方需要把对象转化为字节序列才可在网络上传输,称为对象序列化: 接收方则需 ...
- maven install 找不到符号问题
看报错信息是找不到 javax.servlet 包 .这个是tomcat 内的jar包.但是我build path 查看是加了tomcat 的.. 最后在pom.xml 添加依赖 <depend ...
- java 检查异常 和 非检查异常
个人见解 ,如果有问题 ,还希望大神们 指正 1. 非检查异常 又称运行时 异常 ,所有 继承自 RuntimeException 的异常都是 非检查异常 ,, 如果你不处理 会有 虚拟机 mai ...
- ros pluginlib 段错误
最近在重新回看ROS插件时,运行出现了段错误,发现是boost版本问题,我目前版本是1.66,应该调整至1.58版本,如果跟其他软件使用不同的boost版本时,可以把相应版本编译到本地,不instal ...
- 嵌入式操作系统VxWorks中网络协议存储池原理及实现
嵌入式操作系统VxWorks中网络协议存储池原理及实现 周卫东 蔺妍 刘利强 (哈尔滨工程大学自动化学院,黑龙江 哈尔滨,150001) 摘 要 本文讨论了网络协议存储池的基本原理和在嵌入式操作系 ...
- unity延时函数
新建一个工具类 public class DelayToInvoke : MonoBehaviour{ public static IEnumerator DelayToInvokeDo(Action ...
- 2018.11.28 poj3294 Life Forms(后缀数组+双指针)
传送门 后缀数组经典题目. 我们先把所有的字符串都接在一起. 然后求出hththt数组和sasasa数组. 然后对于sasasa数组跑双指针统计答案. 如果双指针包括进去的属于不同字符串的数量达到了题 ...
- android studio友盟分享demo运行报错Gradle's dependency cache may be corrupt解决方法
gradle-wrapper.properties里修改了gradle的版本,与之前没有报错的项目gradle版本一致.
- Le Chapitre IX
Je crois qu'il profita, pour son évasion[evazjɔ̃]逃跑, d'une migration d'oiseaux sauvages[sovaʒ]未驯化的. ...
- CHAPITRE III
Il me fallut longtemps pour comprendre d'où il venait. Le petit prince, qui me posait beaucoup de qu ...