wpf - Xaml:按钮角半径全局样式
问题描述
我在 xaml 中有以下代码来设置按钮的角半径。如何为应用程序中的所有按钮定义全局样式以具有恒定的角半径?
<Button Content="Exit" MinWidth="65" Background="#b82c2c" Foreground="#fff" BorderThickness="0"
Height="25" VerticalAlignment="Bottom" >
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="5"/>
</Style>
</Button.Resources>
</Button>
解决方案
在 中声明具有边框样式的全局按钮样式Style.Resources
:
<Application.Resources>
<Style TargetType="Button">
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="5"/>
</Style>
</Style.Resources>
</Style>
</Application.Resources>
推荐阅读
- itext - 如何为 Textricator PDF OCR 阅读器设置 FSM 配置?
- mongodb - 无法连接到 Mongo DB 中的主机
- node.js - 在聊天应用程序中跟踪在线或离线信息
- c# - 这到底是在告诉我做什么?
- html - Bootstrap 网格不会为手机重新缩放,但是当我手动输入宽度时会重新缩放
- raptor - raptor 数据验证,因此可以计算一个数字但不接受浮点数?
- python - Asyncio:为每个子线程创建一个事件循环
- html - 在缩放图像上使用绝对定位的 CSS 会导致图像的进一步缩放
- c++ - 如何更新 WinAPI ListView 中特定项目的特定子项目?
- flutter - 使用 Riverpod 进行状态管理