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

C#按钮样式设置XMAL

统一按钮样式

<Window.Resources> <!--按钮样式统一设置,个别按钮单独定义样式的话则需要在定义按钮位置单独设置--><Style TargetType="Button"><Setter Property="Background" Value="Red"/><Setter Property="FontSize" Value="20"/><Setter Property="Height" Value="50"/><Setter Property="Width" Value="300"/></Style>
</Window.Resources>

设置多个样式,并引用。

    <Window.Resources> <!--按钮样式统一设置,个别按钮单独定义样式的话则需要在定义按钮位置单独设置--><Style x:Key="LoginStyle" TargetType="Button"><Setter Property="Background" Value="Blue"/><Setter Property="FontSize" Value="20"/><Setter Property="Height" Value="50"/><Setter Property="Width" Value="300"/></Style><Style x:Key="QuitStyle"  TargetType="Button"><Setter Property="Background" Value="Red"/><Setter Property="FontSize" Value="20"/><Setter Property="Height" Value="50"/><Setter Property="Width" Value="300"/></Style></Window.Resources><StackPanel><Button Style="{StaticResource LoginStyle}" Content="登陆" Width="200" Height="50" FontSize="20"/><Button Style="{StaticResource QuitStyle}" Content="退出" Width="200" Height="50" FontSize="20"/></StackPanel>

设置button的基础样式样式,然后继承基础样式,构建多个不同的样式

   <Window.Resources> <Style TargetType="Button"> <!--设定一个基础的样式:属于全局应用--><Setter Property="Background" Value="WhiteSmoke"/><Setter Property="FontSize" Value="20"/><Setter Property="Margin" Value="20,10,20,10"/></Style><!--继承基础样式的基础生成新的样式1--><Style x:Key="LoginStyle" TargetType="Button" BasedOn = "{StaticResource {x:Type Button} }"><Setter Property="Background" Value="Green"/></Style><!--继承基础样式的基础生成新的样式2--><Style x:Key="QuitStyle" TargetType="Button" BasedOn = "{StaticResource {x:Type Button} }"><Setter Property="Background" Value="Red"/></Style></Window.Resources><StackPanel><Button  Style="{StaticResource LoginStyle}" Content="登陆" Width="200" Height="50" FontSize="20"/><Button  Style="{StaticResource QuitStyle}" Content="退出" Width="200" Height="50" FontSize="20"/></StackPanel>

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

相关文章:

  • EmmyLua注释详解
  • Linux内核 -- 启用 Linux 内核调试信息
  • vs2019 无法打开QT的UI文件
  • Python | A + B问题|||
  • JRT连接希森美康出图
  • UVa11604 General Sultan
  • USB - ACK、NAK和STALL的含义
  • 查看 WSL2 (Windows Subsystem for Linux 2) IP 地址
  • 如何判断一个JavaScript对象是否为空?
  • 小白跟做江科大32单片机之LED闪烁
  • “世界酒中国菜”系列活动如何助推乡村振兴和文化交流?
  • 上位机图像处理和嵌入式模块部署(f407 mcu中fatfs中间件使用)
  • LeetCode/NowCoder-栈和队列OJ练习
  • VSCODE终端输出中文乱码 菱形问号?
  • 域名绑定ip和端口的方法是什么?
  • 视频监控平台AS1000:通过网络SDK接入松下视频监控设备(Panasonic监控摄像机) 的源代码的函数和功能介绍及分享
  • GitLab项目中添加用户,并设置其角色权限等
  • asio之winsock的初始化
  • 打造智能化未来:智能运维系统架构解析与应用实践
  • 【GeoServer系列】——安装与发布shapefile数据
  • Rust 第三方库创建和导入(cargo --lib)
  • node-sass和sass-loader安装Error经验
  • LabVIEW车体静强度试验台测控系统
  • 软件测试进阶
  • 将字符串 “()“ ““ “|“ 条件组成的复杂表达式转换为ES查询语句
  • 2024上半年软考 考试心得
  • 【redis】set和zset常用命令
  • 【面试题-006】java中的垃圾回算法有哪些?
  • 最小时间差
  • 动态SQL IF语句