转载于:http://nishantrana.wordpress.com/2009/03/26/using-hyperlink-in-wpf-application/

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 ….

相关文章:

  • 2022-12-23
  • 2021-12-24
  • 2021-11-19
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-22
  • 2021-12-23
  • 2021-10-01
  • 2022-02-14
  • 2021-06-11
  • 2022-12-23
  • 2021-08-20
相关资源
相似解决方案