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.输入框可设 ...
随机推荐
- Vue热更新报错(log.error('[WDS] Errors while compiling. Reload prevented.'))
log.error('[WDS] Errors while compiling. Reload prevented.');中的WDS其实是webpack-dev-serverwebpack的意思,用来 ...
- The Django Book第七章(表单)
从Request对象中获取数据 在views函数里.我们常常写到 from django.http import HttpResponse def hello(request): return Htt ...
- 【转载】 Jointwave零延时视频传输for FPGA/ASIC进入军工领域
半导体知识产权H.264/H.265 硅IP核供应商Jointwave公司的发布了一系列视频编解码RTL IP核,已经成功应用于军事工业领域的指挥作战,无人机UAV控制,航空和航天摄像机,视频记录黑匣 ...
- Servlet 知识点 中文乱码的本质与解决
本质原因:在servlet中出现中文乱码的原因编码和解码采用的不是一个编码表或者两个编码表不是兼容 例如UTF-8编码.GBK编码都可以读取中文,那么如果采用UTF-8编码保存文件,但是采用GBK编码 ...
- swift - 导航设置总结加深记忆
一.创建导航 let VC=ViewController() let navigationC = UINavigationController(rootViewController: V ...
- 2018.12.15 spoj Substrings(后缀自动机)
传送门 后缀自动机基础题. 求长度为iii的子串出现次数的最大值. 对原串建出samsamsam,然后用sizsizsiz更新每个maxlenmaxlenmaxlen的答案. 然后由于后缀链接将其转化 ...
- git安装项目步骤
1.git clone git@gitee(github).com:项目地址.git 2.cd 项目根目录 3.composer install 4.如果需要数据迁移,cmd中到项目根目录 php a ...
- 微信小程序请求数据
微信小程序请求数据,在页面展示,可以在onLoad生命周期中进行请求. 1.新建目录http,新建文件http.js 2.在js文件中暴露需要使用的变量 var baseUrl = 'http://1 ...
- RNN与应用案例:注意力模型与机器翻译
1. 注意力模型 1.2 注意力模型概述 注意力模型(attention model)是一种用于做图像描述的模型.在笔记6中讲过RNN去做图像描述,但是精准度可能差强人意.所以在工业界,人们更喜欢用a ...
- FastDFS分布文件系统Java客户端集成
参考博客:http://blog.csdn.net/xyang81/article/details/52847311 官网Java客户端源代码: https://github.com/happyfis ...