Hyperlinks in WPF Continued

I wrote before about using hyperlinks in WPF. For my new side project I need to switch from hypertext to the simple text depending on availability of URL. Switching to simple text seemed easy, just assigning text value to the Text property worked. Switching back was not obvious for me.

Then I found that TextBlock has Inlines property. The code became this:

if (!string.IsNullOrEmpty(uri))
if (!string.IsNullOrEmpty(value))
tHypertext.NavigateUri = new Uri(uri);
tTextBlock.Text = value;
tHypertext.NavigateUri = null;

Where TextBlock and Hypertext are from previouse example

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>