如何在WPF中设置标签的字体粗细?

Dan*_*iel 7 .net wpf

我无法找到动画故事板类型,它允许我将标签的FontWeight属性设置为"Normal"到"Bold".有人对这个有经验么?

Mal*_*olm 17

假设标签的FontWeight初始为Normal,如下所示:

<Label x:Name="label" Content="Label" HorizontalAlignment="Left" FontWeight="Normal" VerticalAlignment="Top"/>
Run Code Online (Sandbox Code Playgroud)

您可以使用以下故事板将标签的FontWeight设为Bold:

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