在屏幕截图中,鼠标结束按钮之前,在运行时左边的按钮。
右边的同样的按钮是当鼠标在按钮上方时,按钮周围有一些黑色边框,使得按钮看起来像按钮的大小有了一点增长。这就是我要禁用的东西。
我现在发现,即使我改变颜色为透明的按钮,控制大小仍然增长,当鼠标是在按钮之上。
<Setter TargetName="border" Property="BorderBrush" Value="Transparent" />把它从黑色改为透明,但没有帮助。

我在解决方案资源管理器名称: ResourceDictionaries中创建了一个新文件夹,在该文件夹中创建了一个文件名Dictionary1.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border"
BorderThickness="1"
Padding="4,2"
BorderBrush="DarkGray"
CornerRadius="3"
Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="BorderBrush" Value="Black" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>然后更新App.xaml文件:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ResourceDictionaries/Dictionary1.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>发布于 2022-05-05 20:13:29
工作解决方案:
在Dictionary1.xaml文件中删除行:
<Setter TargetName="border" Property="BorderBrush" Value="Black" />在触发标签之间完成了任务。
https://stackoverflow.com/questions/72132712
复制相似问题