<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圆角按钮例程的更多相关文章

  1. WPF圆角按钮与触发颜色变化

    <Button x:Name="button1" Content="按钮1" Margin="10,10,0,0" Cursor=&q ...

  2. WPF圆角按钮

    <ControlTemplate x:Key="CornerButton" TargetType="{x:Type Button}"> <Bo ...

  3. android 圆角按钮和按钮颜色

    1. android 设置圆角按钮后,按下按钮后,还能改变按钮的颜色 <?xml version="1.0" encoding="UTF-8"?> ...

  4. win10 uwp 圆角按钮

    本文讲的是如何做圆角按钮,我们在UWP本来的按钮都是矩形,圆角Radius没有,所以本文就用简单方法去做圆角按钮. 我们按钮需要圆角,而自带没有,其实做一个很简单,把原来的按钮变为背景透明,然后使用矩 ...

  5. WPF解决按钮上被透明控件遮盖时无法点击问题

    原文:WPF解决按钮上被透明控件遮盖时无法点击问题 IsHitTestVisible="False" 在控件上设置如上属性即可,即可让透明控件不触发点击效果

  6. iOS中创建自定义的圆角按钮

    iOS中很多时候都需要用到指定风格的圆角按钮,尽管UIButton提供了一个方式创建圆角按钮: + (id)buttonWithType:(UIButtonType)buttonType;//指定bu ...

  7. WPF 圆角textbox

    原文:WPF 圆角textbox 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/a771948524/article/details/9245965 ...

  8. [C# WPF] 根据按钮动态跳转窗体

    WPF 根据按钮动态跳转窗体 XMAL文件中,用Tag保存要跳的页面 <Button Name="btnWindow01" Content="ClickMe&quo ...

  9. Qt 圆角按钮,面版自动布局

    一.前言 在部分界面开发中,有时需要动态添加控件或按钮到面板中,在不需要时又需要删除该控件,故模仿视频开发中的设置屏蔽词,通过自己绘制的按钮与排布面板控件实现. 实现效果如下: 说明: 1.输入框可设 ...

随机推荐

  1. Java学习笔记:23种设计模式

    设计模式(Design pattern)的定义: In software engineering, a software design pattern is a general, reusable s ...

  2. Tgrocery学习及使用

    能够学习到短文本分类模型——Tgrocery,十分感谢@GavinBuildSomething把源码及测试数据分享,在此我也作为一名学习者将自己的学习过程记录下来,希望对其他人有所帮助.   1.学习 ...

  3. 155. Min Stack - Unsolved

    https://leetcode.com/problems/min-stack/#/solutions Design a stack that supports push, pop, top, and ...

  4. MySQL open_files_limit相关设置

    背景:      数据库链接不上,报错: root@localhost:/var/log/mysql# mysql -uzjy -p -h192.168.1.111 --default-charact ...

  5. Django的学习(一)————初入django

    一.基本指令 1.项目的建立: Django的项目建立,进入目录,打开cmd输入 django-admin startproject[项目名称],注意如果是在其他文件下把项目设计成资源文件. 2.Ap ...

  6. HTML-入门篇day01

    HTML-入门篇day01 1.web     C/S:Client Server    客户端 服务器    QQ,...    B/S:Browser Server    浏览器 服务器 PC机: ...

  7. Linux服务器上新增开放端口号

    开放端口的方法: 方法一:命令行方式               1. 开放端口命令: /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT    ...

  8. MySQL mysqldump 数据备份

    1.mysqldump 命令工具说明 参数注解: mysqldump 是采用SQL 级别的备份机制,它将数据表导成 SQL 脚本文件,在不同的 MySQL 版本之间升级时相对比较合适,这也是最常用的备 ...

  9. Spring Boot项目简单上手+swagger配置+项目发布(可能是史上最详细的)

    Spring Boot项目简单上手+swagger配置 1.项目实践 项目结构图 项目整体分为四部分:1.source code 2.sql-mapper 3.application.properti ...

  10. 研究生flag

    是时候定个计划了,感觉日子一天天水,不加油学点东西,迟早要掉队…… 刷刷算法题库吧,貌似选几个管用的刷刷——https://hihocoder.com/problemset 争取明年三月份的PAT顶级 ...