zoukankan      html  css  js  c++  java
  • 在WPF应用中添加超链接

    转载于: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 ….

  • 相关阅读:
    2015 多校联赛 ——HDU5389(dp)
    spring MVC配置详解
    面试题整理11
    面试题整理09
    Spring和SpringMVC的区别
    SpringMVC01
    js中typeof与instanceof用法小记
    Java 可变参数
    log4j文件的配置
    Hibernate 分组查询 子查询 原生SQL
  • 原文地址:https://www.cnblogs.com/MarcLiu/p/3723020.html
Copyright © 2011-2022 走看看