Export (0) Print
Expand All

Create a hyperlink in a TextBlock or RichTextBox

You can create a hyperlink inside a TextBlock or RichTextBox object that will navigate to another document in your application, or to a web page.

Create a hyperlink in a WPF project

If you are working in a Windows Presentation Foundation (WPF) project, you can create hyperlinks only in a Page document, and thus in a NavigationWindow object. (To create a new Page document, on the File menu, click New Item, and then click Page.) The linked-to topic must be either a Page document in your application or a web page.

To create a hyperlink in a TextBlock in a WPF project

  1. In the Tools panel, click either Selection Cc294844.2ff91340-477e-4efa-a0f7-af20851e4daa(en-us,Expression.40).png or Direct Selection Cc294844.6dd6571f-c116-451d-8dd2-1f88b8406362(en-us,Expression.40).png.

  2. Click to select the TextBlock object to which you want to add a hyperlink, right-click the object, and then click Edit Text.

  3. Do one of the following:

    • To apply a hyperlink to existing text, drag to select the text.

    • To create a hyperlink from scratch, click where you want the hyperlink text to appear.

  4. In the Properties panel, under Text, on the Font tab Cc294844.17db489b-22e6-4b99-9a19-fa1ed9d51e7e(en-us,Expression.40).png, click Hyperlink Cc294844.d2081be0-6c8a-4861-9bef-c08dfb040102(en-us,Expression.40).png.

  5. In the Create Hyperlink dialog box, enter the text that you want to be hyperlinked next to Hyperlink Text, enter the URL or URI (Universal Resource Identifier) for the link next to Hyperlink URI, and then click OK.

To create a hyperlink in a RichTextBox in a WPF project

  1. In the Tools panel, click either Selection Cc294844.2ff91340-477e-4efa-a0f7-af20851e4daa(en-us,Expression.40).png or Direct Selection Cc294844.6dd6571f-c116-451d-8dd2-1f88b8406362(en-us,Expression.40).png.

  2. Click the RichTextBox object to which you want to add a hyperlink. In the Properties panel, do the following:

    • In the Common Properties category, select IsDocumentEnabled.

    • In the Text category, select IsReadOnly.

  3. Right-click the RichTextBox object to which you want to add a hyperlink, and then click Edit Text.

  4. Do one of the following:

    • To add a hyperlink to existing text, drag to select the text.

    • To create a hyperlink from scratch, click where you want the hyperlink text to appear.

  5. In the Properties panel, under Text, on the Font tab Cc294844.17db489b-22e6-4b99-9a19-fa1ed9d51e7e(en-us,Expression.40).png, click Hyperlink Cc294844.d2081be0-6c8a-4861-9bef-c08dfb040102(en-us,Expression.40).png.

  6. In the Create Hyperlink dialog box, type the text that you want to be hyperlinked next to Hyperlink Text, type the URL or URI (Universal Resource Identifier) for the link next to Hyperlink URI, and then click OK.

Create a hyperlink in a Silverlight project

If you are working in a Microsoft Silverlight project, you can create hyperlinks in all document types if you are using a RichTextBox with the IsReadOnly property set to True. However, Silverlight does not support hyperlinks in TextBlock objects.

To create a hyperlink in a RichTextBox in a Silverlight project

  1. In the Tools panel, click either Selection Cc294844.2ff91340-477e-4efa-a0f7-af20851e4daa(en-us,Expression.40).png or Direct Selection Cc294844.6dd6571f-c116-451d-8dd2-1f88b8406362(en-us,Expression.40).png.

  2. Select the RichTextBox object to which you want to add a hyperlink. In the Properties panel, in the Text category, select IsReadOnly.

  3. Right-click the RichTextBox object to which you want to add a hyperlink, and then click Edit Text.

  4. Do one of the following:

    • To apply a hyperlink to existing text, drag to select the text.

    • To create a hyperlink from scratch, click where you want the hyperlink text to appear.

  5. In the Properties panel, under Text, on the Font tab Cc294844.17db489b-22e6-4b99-9a19-fa1ed9d51e7e(en-us,Expression.40).png, click Hyperlink Cc294844.d2081be0-6c8a-4861-9bef-c08dfb040102(en-us,Expression.40).png.

  6. In the Create Hyperlink dialog box, type the text that you want to be hyperlinked next to Hyperlink Text, type the URL or URI (Universal Resource Identifier) for the link next to Hyperlink URI, and then click OK.

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.
Show:
© 2014 Microsoft