【问题标题】:Underline button content on PointerOverPointerOver 上的下划线按钮内容
【发布时间】:2013-12-17 02:40:31
【问题描述】:

我正在尝试使用 VisualStates 为按钮的内容添加下划线,但我没有这样做。

理想情况下,我很乐意这样做,就像我可以更改内容的 FontWeight 一样,

<VisualState x:Name="PointerOver">
    <Storyboard>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="FontWeight" Storyboard.TargetName="ContentPresenter">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Bold"/>
        </ObjectAnimationUsingKeyFrames>
    </Storyboard>
</VisualState>

但以下无效,

<VisualState x:Name="PointerOver">
    <Storyboard>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="FontStyle" Storyboard.TargetName="ContentPresenter">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Underline"/>
        </ObjectAnimationUsingKeyFrames>
    </Storyboard>
</VisualState>

我已经阅读了 Underline 类以及如何将它与 Runs 一起使用,但发现无法使用 VisualStates 来做到这一点。

有没有办法做到这一点?或任何其他方式来切换 PointerOver 上按钮内容的下划线效果?

提前致谢。

【问题讨论】:

    标签: xaml windows-store-apps


    【解决方案1】:

    “但以下是抛出异常”没有帮助。了解 WHICH Exception 和 WHICH 错误消息可能会有所帮助。

    但是,要为某些内容下划线,请不要将“FontStyle”而是“TextDecorations”设置为“Underline”

    【讨论】:

    • 感谢您的反馈。我已将问题编辑为更清楚。此外,由于它具有误导性,我对此投了反对票,而 TextDecorations 在 WPF 上,它不在 Windows 应用商店中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 1970-01-01
    • 1970-01-01
    • 2016-03-13
    • 2015-10-29
    • 1970-01-01
    • 2011-08-29
    相关资源
    最近更新 更多