0

I'm trying to underline the content of a button using VisualStates but I'm failing to do so.

Ideally, I'd love to do it the same way I can change the FontWeight of the content,

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

But the following is not valid,

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

I've read about the Underline class and how you can use it with Runs but found no way to do this using VisualStates.

Is there a way of doing this? Or any other way to toggle an underlined effect on the content of a button on PointerOver?

Thanks in advance.

mcabral
  • 3,524
  • 1
  • 25
  • 42

1 Answers1

-1

"But the following is throwing an exception" isn't helpful. It might help to know WHICH Exception and WHICH error message.

However, to underline something you don't set "FontStyle" but "TextDecorations" to "Underline"

HDW Production
  • 1,402
  • 10
  • 13
  • Thanks for your feedback. I've edited the question to be more clear. Also, I've downvoted this since it is misleading, while TextDecorations is on WPF, it is not in Windows Store. – mcabral Dec 17 '13 at 14:12