Home » SilverlightRSS

Hyperlink within Textblock

Hi All

Is it possible to provide hyperlink to a part of text in a textblock, as we can do in HTML?

like this:

Please Click here to open the link.

 

14 Answers Found

 

Answer 1

Hello, you need to use a HyperlinkButton instead of a normal TextBlock.

 

Answer 2

Suppose I have a long paragraph & I need to hyperlink a few words inbetween. I don't think its a good idea to break that into textblocks and place few Hyperlink buttons here and there & thats also not going to give it a proper look. Is there any solution for that kind of a situation?

 

Answer 3

If you're looking for true rich text, Silverlight 2 doesn't support it... But you should be able to find some rich text Controls, such as this one (It was written for Beta 2, you need to upgrade it to RTW).

 

Answer 4

 SL Final Release is here! Is there still no support for adding hyperlinks to text within a paragraph????

 

Answer 5

 Hello Man,

 

Yes you can do it... 

 Copy the code below and thats it.. 

<TextBlock HorizontalAlignment="Left" Margin="11.816,7.928,0,0.012" Width="115" Grid.Column="1" Grid.Row="3" TextWrapping="Wrap">

                <Hyperlink NavigateUri="http://code.logos.com/blog/"><Run Text="Your TextHERE"/>

                </Hyperlink>

</TextBlock>

 

Answer 6

A simple but effective way to achieve this, is by using textblocks and hyperlink buttons inside a StackPanel with a horizontal orientation, this way you can add your text, then the hyperlink, and if needed more text, it will look good because you can adjust the margin of the hyperlinkbutton UIElement to space out correctly.

try the following...

<StackPanel Height="Auto" Orientation="Horizontal" Width="143">
            <TextBlock Height="Auto" Width="Auto" Text="Click in "/>
            <HyperlinkButton Height="Auto" Width="Auto" Content="Here"/>
            <TextBlock Height="Auto" Width="Auto" Text="To navigate."/>
</StackPanel>

 

Answer 7

 This is not valid. <Hyperlink> is not a valid tag. 

 

Answer 8

Menwhile I came up with the idea of a class that handle pseudo code like <b> = Bold, <s> = Size, <u> = Underline and <l> = link

So the goal is to make the class that inehrits a TextBlock, handling those and provide formating as well as hyperlink.
Example :

"Come to <s><b>MIX09</b>||32</s>.  <l>REGISTER NOW||http://mix09.com</i>, this is the next web now"
Pipes are to know what to set for this tag like the size or the link

See what I mean.  Oh and for hyperlink.  I think TextDecorations is working for this scenario.
Now I need to know how the click event works for the link in C# code behind with TextDecorations

 

Answer 9

Any RichTextBox support in SilverLight 3 ?

 

 

Answer 10

Snippet

I accomplished this using a Rich Text Box:

<RichTextBoxIsReadOnly="True" Background="Transparent" BorderBrush="{x:Null}" BorderThickness="0" AcceptsReturn="False">
<Paragraph>
  <Run Text="All of my Fancy Text Goes here.. "></Run>                       
    <Hyperlink NavigateUri="http://www.microsoft.com" TargetName="_blank">
    <Run Text="and this is the link." />
    </Hyperlink>
</Paragraph>
</RichTextBox>

--
Chris Mullins
 

Answer 11

Hi,

What do we have with SL4 when  huge text comes from a call to WCF which the data was taken from SQL and in the text, there's a few Hyperlinks and email links.  How do these links will be formated correctly automatically.  Which control will does that ?

I can't imagine myself going throught all the text and look for links and format them with run in a RichTextBox ?

Any ideas ?

 

 

Answer 12

Didn't see any answer to the previous question; does anyone know if this would be available in SL4 or if there is a rich-text control?  I agree with the previous poster, it would be tedious to parse the textblock text looking for hyperlinks and formatting them individually.

 

Answer 13

I think we are left alone with all the richtextbox capabilities fragmented so we can make anything but at what price ?
 

Answer 14

Well, that's it exactly.  There are always more important things to work on than extending the controls.

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter