Open a hyperlink URI (www.google.com) in a web browser( IE or chrome) through code in C# WPF forms -


im working on project has hyperlinks in it. used datagridhyperlinkcolumn populate uri's in single column. whenever click on uri, gets opened in both browser , wpf window. prevent uri opening in web browser using hyperlink.requestnavigate().

but need uri opened in web browser , not in wpf window. have attached xaml , c# code below.

<datagrid name="dgusers"  autogeneratecolumns="false" canuseraddrows="false" borderthickness="0" canuserresizerows="false" gridlinesvisibility="none" headersvisibility="none" focusable="false" visibility="{binding dgvisibility}">             <datagrid.resources>                 <style targettype="hyperlink">                     <eventsetter event="click" handler="dg_hyperlink_click"/>                 </style>             </datagrid.resources>             <datagrid.columns>                  <datagridhyperlinkcolumn binding="{binding website}"  width="*" canuserresize="false" canusersort="false" isreadonly="true"  >                 <datagridhyperlinkcolumn.elementstyle>                     <style>                         <!--eventsetter event="hyperlink.click" handler="dg_hyperlink_click"/-->                     </style>                 </datagridhyperlinkcolumn.elementstyle>             </datagridhyperlinkcolumn>         </datagrid.columns>     </datagrid> 

c# code follows below.

 public mainwindow()  {     initializecomponent();      list<user> users = new list<user>();     users.add(new user() { website = new uri("http://www.google.com") });     users.add(new user() { website = new uri("http://www.yahoo.com") });     users.add(new user() { website = new uri("http://www.gmail.com") });     //dgvisibility = visibility.hidden;     //userslink = users;     dgusers.itemssource = users;   }   public class user  {      public uri website { get; set; }  }   private void dg_hyperlink_click(object sender, routedeventargs e)  {      hyperlink link = (hyperlink)e.originalsource;      process.start(new processstartinfo(link.navigateuri.absoluteuri));  } 

thanks in advance.

copied comments:

use text column custom template containing text only, interaction trigger bind mouse click handler.

add style foreground set red/blue on mouseover trigger mimic url , feel. hyperlink control does.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -