locked
Removing underline from inline Hyperlink

    Question

  • I have some inline Hyperlinks in my TextBlock which I want to be displayed without their underline.

    How do I remove it now TextDecorations is no longer a property?

    Would be ideal if I could do this using a style so they are removed in all hyperlinks in my page.

    Wednesday, May 07, 2014 10:35 AM

Answers

  • I got around this by using inline TextBlocks and specifying t6he color. Only draw back of this was that there is no Click event to use - however you can use Tapped.
    • Marked as answer by BradStevenson Wednesday, December 17, 2014 6:21 PM
    Wednesday, December 17, 2014 6:20 PM

All replies

  • As an aside? How would you know they are hyperlinks then?

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Wednesday, May 07, 2014 12:57 PM
    Moderator
  • If I just used underlines to identify the hyperlinks its easy for them to get lost within the text as I can have many hyperlinks in a small passage of text, therefore I'm using a different color to differentiate it from normal text.

    However the combination of separate colouring and underlines can cause the text to look cluttered and visually unappealing.



    Wednesday, May 07, 2014 1:17 PM
  • Got ya.  So yes.  You could use XAML and <Run> elements to customize the format.  You would need to manually build the text.  Do you have a copy of Programming Windows Sixth Edition?  I covers this in detail.

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Wednesday, May 07, 2014 1:20 PM
    Moderator
  • I'm already manually building the text currently would have a sequence like this:

    <Paragraph xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> <Run>Behold some textual content! </Run> <Hyperlink NavigateUri="http://bing.com">bing.com</Hyperlink>

    <Run></Run> </Paragraph>


    So how would I go about using the <Run> elements to remove the underline styling?


    Friday, May 16, 2014 5:28 PM
  • Wait, You want the Hyperlink to not appear as a Hyperlink but behave like one?  How would the user know it is one?

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Friday, May 16, 2014 5:35 PM
    Moderator
  • See my prior comment ^ in my particular use case I'm using colour instead of underlines as the visual indicator for tappable text.
    Friday, May 16, 2014 5:50 PM
  • Is this possible or not?

    Seems like it wont be now as TextDecorations property has been replaced with <Underline> which cant be used to remove existing underlines.

    Wednesday, May 28, 2014 10:28 AM
  • I have not had time to look at this yet.  I suspect no.

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Wednesday, May 28, 2014 2:29 PM
    Moderator
  • i have this xaml:

        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock FontSize="30">
                
    
                        <Run>Behold some textual content!</Run>
                        <Hyperlink NavigateUri="http://bing.com">bing.com</Hyperlink>
                        <Run></Run>
    
    
            </TextBlock>
        </Grid>

    and this was the result:

    and as you see no underline?


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, May 28, 2014 7:23 PM
  • It is not true with windows phone 8.1 RT project, it displays correctly in XAML designer, but with underline in device
    Wednesday, September 17, 2014 8:08 PM
  • I got around this by using inline TextBlocks and specifying t6he color. Only draw back of this was that there is no Click event to use - however you can use Tapped.
    • Marked as answer by BradStevenson Wednesday, December 17, 2014 6:21 PM
    Wednesday, December 17, 2014 6:20 PM
  • lol. sorry this was a terrible question. It's like you've never used a website before in your life;)
    Tuesday, January 06, 2015 5:12 AM
  • Well, using TextBlock's instead of inline hyperlink as you should be able to is terrible. Ended having to botch so many event handlers as TextBlocks and InlineHyperlinks have very different behaviour.
    Tuesday, January 06, 2015 8:28 AM