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.

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.

  1. In the Tools panel, click either SelectionJJ170623.2ff91340-477e-4efa-a0f7-af20851e4daa(fr-fr,VS.110).png or Direct SelectionJJ170623.6dd6571f-c116-451d-8dd2-1f88b8406362(fr-fr,VS.110).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 JJ170623.17db489b-22e6-4b99-9a19-fa1ed9d51e7e(fr-fr,VS.110).png, click Hyperlink JJ170623.d2081be0-6c8a-4861-9bef-c08dfb040102(fr-fr,VS.110).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.

  1. In the Tools panel, click either SelectionJJ170623.2ff91340-477e-4efa-a0f7-af20851e4daa(fr-fr,VS.110).png or Direct SelectionJJ170623.6dd6571f-c116-451d-8dd2-1f88b8406362(fr-fr,VS.110).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 JJ170623.17db489b-22e6-4b99-9a19-fa1ed9d51e7e(fr-fr,VS.110).png, click Hyperlink JJ170623.d2081be0-6c8a-4861-9bef-c08dfb040102(fr-fr,VS.110).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.

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.

  1. In the Tools panel, click either SelectionJJ170623.2ff91340-477e-4efa-a0f7-af20851e4daa(fr-fr,VS.110).png or Direct SelectionJJ170623.6dd6571f-c116-451d-8dd2-1f88b8406362(fr-fr,VS.110).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 JJ170623.17db489b-22e6-4b99-9a19-fa1ed9d51e7e(fr-fr,VS.110).png, click Hyperlink JJ170623.d2081be0-6c8a-4861-9bef-c08dfb040102(fr-fr,VS.110).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.