当前位置: 首页 > news >正文

WPF学习(2) -- 样式基础

一、代码

<Window x:Class="学习.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:学习"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Window.Resources><Style x:Key="BaseButtonStytle" TargetType="Button"><!--创建一个按键的公用基础样式--><Setter Property="FontSize" Value="20"/><!--字体大小--><Setter Property="Foreground" Value="Black"/><!--字体颜色--><Style.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Background" Value="LightBlue"/> <!--鼠标悬浮会变蓝色--></Trigger></Style.Triggers></Style><Style x:Key="ButtonStytle" TargetType="Button" BasedOn="{StaticResource BaseButtonStytle}"><!--继承共用基础样式的按键样式--><Setter Property="Background" Value="Green"/><!--按键背景为绿色--></Style></Window.Resources><Grid><StackPanel><Button Content="111" Style="{StaticResource ButtonStytle}" /><Button Content="111" Style="{StaticResource ButtonStytle}" /><Button Content="111" Style="{StaticResource ButtonStytle}" /></StackPanel></Grid>
</Window>

二、结果

http://www.lryc.cn/news/399616.html

相关文章:

  • 独家揭秘!五大内网穿透神器,访问你的私有服务
  • Ubuntu 编译和运行ZLMediaKit
  • 基于JavaSpringBoot+Vue+uniapp微信小程序校园宿舍管理系统设计与实现
  • Hive的基本操作(创建与修改)
  • Linux开发讲课37--- ARM的22个常用概念
  • 7-1、2、3 IPFS介绍使用及浏览器交互(react+区块链实战)
  • CentOS 7 中出现 cannot open Packages database in /var/lib/rpm 错误
  • 【java深入学习第6章】深入解析Spring事件监听机制
  • Flask与Celery实现Python调度服务
  • Eureka应用场景和优势
  • prompt第三讲-PromptTemplate
  • 卷积神经网络图像识别车辆类型
  • 【接口设计】用 Swagger 实现接口文档
  • TensorFlow系列:第四讲:MobileNetV2实战
  • Redis+Caffeine 实现两级缓存实战
  • SpringBoot:SpringBoot中如何实现对Http接口进行监控
  • STM32-I2C硬件外设
  • 暑假第一次作业
  • 【算法专题】快速排序
  • debian 12 PXE Server 批量部署系统
  • 【Pytorch】RNN for Image Classification
  • 基于Java的飞机大战游戏的设计与实现论文
  • 初识影刀:EXCEL根据部门筛选低值易耗品
  • nginx的四层负载均衡实战
  • 中职网络安全B模块Cenots6.8数据库
  • BGP笔记的基本概要
  • 【Redis】复制(Replica)
  • 封装了一个仿照抖音效果的iOS评论弹窗
  • 【JavaWeb程序设计】Servlet(二)
  • php探针