WPF button 圆角制作

时间:2020-12-25 10:52:35

将以下节点复制到app.xaml的<Application.Resources>节点下

<Style TargetType="{x:Type Button}">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border Name="Border" Background="{TemplateBinding Control.Background}">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"
                                      Content="{TemplateBinding ContentControl.Content}" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>