To user hyperlink in WPF application we could do something like this
<TextBlock>
<Hyperlink NavigateUri=”http://www.google.co.in”>
Click here
</Hyperlink>
</TextBlock>
However the NavigateUri works only if we are placing the hyperlink within a page. To use it within a windows-based application we need to hanlde the RequestNavigate event and write the code ourselves.
Something like this
<TextBlock>
<Hyperlink NavigateUri=”http://www.google.co.in” RequestNavigate=”Hyperlink_RequestNavigate”>
Click here
</Hyperlink>
</TextBlock>
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
While using hyperlink we could also provide handler for Application.NavigationFailed event in case if navigation fails.
That’s it ….


Thanks. This helped me solve a problem
I’m using the code below. I hope it can help you.
Click here!
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
thanks. but for me it works only like this
Process.Start(new ProcessStartInfo(“mailto:”+e.Uri.ToString()));
Hi,
Just one question, please….
In the code line “Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));”… what stands for Process?? I´m trying to write your code and I got an error regarding that line…
Thanks in advance
[...] on Creating Word document using…chati on Logging off from OracleSiebel…drew on Using Hyperlink in WPF ap…PatrickM on Finding shared records in…Dharm on Sample Code for using IOrganiz… [...]
This doesnt seem to work unless i add a this.DataContext = “something” into my main window class. this is causing issues for me as i have a relativesource binding set to my datacontext in the xaml. how can i get around this? thanks! great article btw
[...] Using Hyperlink in WPF application « Nishant Rana’s Weblog. [...]
Hi,
I am Naga Harish from chennai. I need one help from you. I want write Microsoft certification in ASP.Net. I need your guide lines. You can my gmail ID to send reply (nagaharish.movva@gmail.com) . I have some Q? too. Please help me!
Very helpful. Just want to add that
Application.NavigationFailed EventHandler goes into the App.Xaml class and might look like this:
private void App_NavigationFailed (object sender, NavigationFailedEventArgs e)
{
if (e.Exception is System.Net.WebException)
{
//code to handle error here, such as a messagebox to the user
e.Handled = true;
}
}