.net 是否更改wpf中的按钮边框厚度?
为什么按钮的边框厚度不变 如果我将边框厚度更改为1或100,这并不重要。都一样。我想使用样式更改它,而不是自定义模板.net 是否更改wpf中的按钮边框厚度?,.net,wpf,button,border,thickness,.net,Wpf,Button,Border,Thickness,为什么按钮的边框厚度不变 如果我将边框厚度更改为1或100,这并不重要。都一样。我想使用样式更改它,而不是自定义模板 <Window x:Class="GUI.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" H
<Window x:Class="GUI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="newYellowButton" TargetType="{x:Type Button}">
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="100"/>
<Setter Property="Background">
<Setter.Value>
<RadialGradientBrush Center="0.5,0.5" GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5" SpreadMethod="Pad" ColorInterpolationMode="SRgbLinearInterpolation">
<GradientStop Color="#FFEEEE3B" Offset="0.5" />
<GradientStop Color="#FFF0E49A" Offset="1" />
</RadialGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="9"/>
<Setter Property="BorderBrush" Value="Blue" />
<Setter Property="Padding" Value="-4"/>
</Style>
</Window.Resources>
<Grid>
<Button Style="{StaticResource newYellowButton}" Content="Ok"/>
</Grid>
您可以通过更改。复制那些样式、画笔和。。。到资源字典,然后更改所需的值 要更改边框厚度,请查找以下代码并进行所需更改:
...
<Border
x:Name="Border"
CornerRadius="2"
BorderThickness="1" //CHANGE THIS VALUE
Background="{StaticResource NormalBrush}"
BorderBrush="{StaticResource NormalBorderBrush}">
<ContentPresenter
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
RecognizesAccessKey="True"/>
</Border>
...
。。。
...
对我来说很好,你发布的代码。还尝试了在样式和输出中更改边框厚度。我只是想知道这是否可以在没有模板的情况下实现,仅使用样式。实际上,如果您按照链接进行操作,您会发现,这是一种简单的样式。我编辑了我的帖子。非常感谢你的回答!