Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

c# - WP - how to remove underline in hyperlinkButton programmatically?

I have developed an hyperlinkButton in C#. The underline in hyperlinkButton irritates me. I don't know how to remove it. Help me to remove the underline and i need answer in C#. [It's an WP8 app]

    HyperlinkButton hyperlinkButton = new HyperlinkButton()
    {
        Content = "Click me",
        HorizontalAlignment = HorizontalAlignment.Left,
        NavigateUri = new Uri("http://my-link-com", UriKind.Absolute)
    };
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To quote Douglas Stockwell

You can set properties directly, or use a style:

<Style TargetType="{x:Type Hyperlink}">
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Foreground" Value="DarkSlateBlue" />
        </Trigger>
    </Style.Triggers>
    <Setter Property="Foreground" Value="SteelBlue" />
    <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" />
</Style>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...