gpt4 book ai didi

.net - 如何在 WPF 中为标签的字体粗细设置动画?

转载 作者:行者123 更新时间:2023-12-02 17:59:18 26 4
gpt4 key购买 nike

我无法找到允许我将标签的 FontWeight 属性从“正常”设置为“粗体”的动画 Storyboard类型。有人有这方面的经验吗?

最佳答案

假设标签的 FontWeight 首字母为 Normal,如下所示:

<Label x:Name="label" Content="Label" HorizontalAlignment="Left" FontWeight="Normal" VerticalAlignment="Top"/>

您可以使用以下 Storyboard将标签的 FontWeight 设为粗体:

<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.FontWeight)" Storyboard.TargetName="label">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<FontWeight>Bold</FontWeight>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>

关于.net - 如何在 WPF 中为标签的字体粗细设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3303769/

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