locked
Windows Store App - creating hyperlink from C# RRS feed

  • Question

  • I have the following string:

    Hey man! If you want to search something go to https://www.google.com/ and search for it there.

    How can i  create the same text but containing a hyperlink to the above link, so users can click the link to go to it?

    I want to be able to do this in c#.

    I know how to do it in XAML but no in C#.

    Thank you.

    Tuesday, December 24, 2013 9:18 PM

Answers

  • Hi kalel111,

    I suppose you need show these text in a RichEditBox and you could use this:

                Run run1 = new Run();
                run1.Text = "Hey man! If you want to search something go to ";
                Hyperlink link = new Hyperlink();
                Run run2 = new Run();
                run2.Text = "www.microsoft.com";
                link.NavigateUri = new Uri("https://www.microsoft.com/");
                link.Inlines.Add(run2);
                Run run3 = new Run();
                run3.Text = " and search for it there.";
    
                Paragraph pgh = new Paragraph();
                pgh.Inlines.Add(run1);
                pgh.Inlines.Add(link);
                pgh.Inlines.Add(run3);
                
    
                rtb.Blocks.Add(pgh);

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Proposed as answer by Jamles HezModerator Wednesday, December 25, 2013 1:26 AM
    • Marked as answer by kalel111 Wednesday, December 25, 2013 2:29 AM
    Wednesday, December 25, 2013 1:26 AM
    Moderator