web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Nishant Rana’s Weblog / Using Hyperlink in WPF appl...

Using Hyperlink in WPF application

Nishant Rana Profile Picture Nishant Rana 11,325 Microsoft Employee
To user hyperlink in WPF application we could do something like this
 
<TextBlock>
<Hyperlink NavigateUri=”http://www.google.co.in”&gt;
            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&#8221; 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 ….
 

Posted in .NET Framework Tagged: WPF

This was originally posted here.

Comments

*This post is locked for comments