Xaml: 按钮角半径全局样式

问题描述 投票:-1回答:1

我在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>
wpf windows xaml desktop-application
1个回答
1
投票

在应用程序中声明全局按钮样式和边框样式。Style.Resources:

<Application.Resources>
    <Style TargetType="Button">
        <Style.Resources>
            <Style TargetType="Border">
                <Setter Property="CornerRadius" Value="5"/>
            </Style>
        </Style.Resources>
    </Style>
</Application.Resources>
© www.soinside.com 2019 - 2024. All rights reserved.