移除wpf按钮鼠标上方的奇怪行为
我为一个虚拟问题争论了好几个小时 在wpf中,我希望覆盖移除wpf按钮鼠标上方的奇怪行为,wpf,xaml,button,styles,mouseover,Wpf,Xaml,Button,Styles,Mouseover,我为一个虚拟问题争论了好几个小时 在wpf中,我希望覆盖按钮的行为,并且在达到我想要的基本行为的那一刻(特定颜色) 但我不能简单地说:在鼠标上方添加下划线样式! 我可以添加下划线,但无法删除文本周围的正方形 我使用的样式是: <Style TargetType="Button"> <Setter Property="Foreground" Value="{DynamicResource {x:Static vs_shell:EnvironmentColors.Co
按钮的行为,并且在达到我想要的基本行为的那一刻(特定颜色)
但我不能简单地说:在鼠标上方添加下划线样式!
我可以添加下划线,但无法删除文本周围的正方形
我使用的样式是:
<Style TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs_shell:EnvironmentColors.CommandBarMenuLinkTextBrushKey}}"></Setter>
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="BorderThickness" Value="0"></Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock TextDecorations="Underline" Text="{TemplateBinding Content}" Background="Transparent"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
有什么想法/建议吗
谢谢 也许这会帮助你:
它涉及ListViewItems,但您可以在按钮或任何其他WPF控件上应用此机制
祝你好运将此setter添加到样式中:
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>