看啥推荐读物
专栏名称: dotNET跨平台
专注于.NET Core的技术传播。在这里你可以谈微软.NET,Mono的跨平台开发技术。在这里可以让你的.NET项目有新的思路,不局限于微软的技术栈,横跨Windows,Linux 主流平台
今天看啥  ›  专栏  ›  dotNET跨平台

WPF 如何修改button圆角(经典)

dotNET跨平台  · 公众号  ·  · 2024-02-11 08:15
本人想设置Button为圆角,奈何搜索百度,找到的全是坑爹答案,现总结如下:1. 需要添加button 的template. 2. 设置border的时候,必须要设置background, 否则会提示content 被多次使用。 Button Grid.Row="3" Grid.Column="2" Content="取消" Margin="30,40,200,40" > Button.Template > ControlTemplate TargetType="{x:Type Button}" > Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="7,7,7,7"> Border.Background>#FFDDDDDDBorder.Background> ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" >ContentPresenter> Border> ControlTemplate> Button.Template> Button>我们只需要在XAML中给他添加几行代码就可以做成圆角形状。Button x:Name= ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照