gpt4 book ai didi

wpf - 触发时无法显示下划线

转载 作者:行者123 更新时间:2023-12-02 22:20:38 25 4
gpt4 key购买 nike

我有以下样式,但是当鼠标悬停触发器为真时,文本上不会显示下划线。

<Style x:Key="HyperlinkToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<TextBlock x:Name="TextBlock">
<ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>

<Style.Triggers>
<Trigger Property="IsMouseOver" Value="false">
<Setter Property="Background" Value="{StaticResource StandardBackground}"/>
<Setter Property="Foreground" Value="Black" />
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontStyle" Value="Normal"/>
<Setter Property="FontWeight" Value="Normal"/>
</Trigger>

<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="{StaticResource StandardBackground}"/>
<Setter Property="Foreground" Value="{StaticResource StandardBlue}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontStyle" Value="Normal"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="TextBlock.TextDecorations" Value="Underline"/>
</Trigger>
</Style.Triggers>
</Style>

最佳答案

这可能不是理想的解决方案,但您可以在控件模板中定义触发器。不要忘记使用 setter 上的 TargetName 属性引用您的 TextBlock。

    <Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<TextBlock x:Name="TextBlock">
<ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
</TextBlock>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="TextBlock" Property="TextBlock.TextDecorations" Value="Underline"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>

关于wpf - 触发时无法显示下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13751235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com