in

DotNetSide

Dot Net South Italy Developers User Group

Tips

Hyperlink in WPF

Autore: Vito Arconzo

Un quesito ricorrente nei forum su Windows Presentation Foundation è come creare un hyperlink per aprire il browser su una pagina web indicata.

La risposta è differente a seconda se si tratti di un'applicazione standalone o browser.

Browser

Nelle applicazioni di tipo browser la cosa è molto semplice:

<TextBlock> <Hyperlink NavigateUri="http://www.dotnetside.org" TargetName="_top"> Navigate the top-level window to DotNetSide </Hyperlink> </TextBlock>

Standalone

Sfortunatamente, nelle applicazioni standalone, la cosa non è così immediata e il modo più semplice è quello di utilizzare l'evento RequestNavigate del controllo HyperLink e, quindi, gestire l'apertura del browser nel code-behind:

<TextBlock> <Hyperlink RequestNavigate="HandleRequestNavigate" Name="hl"
NavigateUri="http://www.dotnetside.org"> Open DotNetSide in the default browser </Hyperlink> </TextBlock>
void HandleRequestNavigate(object sender, RoutedEventArgs e) { string navigateUri = hl.NavigateUri.ToString(); Process.Start(), e.g. check to see Process.Start(new ProcessStartInfo(navigateUri)); e.Handled = true; }
Only published comments... Oct 17 2006, 09:00 PM by VitoA
Filed under: ,

Comments

 

Twitter Trackbacks for Hyperlink in WPF - Tips [dotnetside.org] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Hyperlink in WPF - Tips         [dotnetside.org]        on Topsy.com

May 13, 2010 9:54 AM
 

Discount Gmc V2500 Suburban S15 Jimmy Sierra Denali, Part Gmc K35 K3500 Pickup Axle Assembly S15 Jimmy said:

Pingback from  Discount Gmc V2500 Suburban S15 Jimmy Sierra Denali, Part Gmc K35 K3500 Pickup Axle Assembly S15 Jimmy

May 20, 2010 4:47 PM
 

S90 Sell Dealers, Volvo S90 Repair Manual Pdf said:

Pingback from  S90 Sell Dealers, Volvo S90 Repair Manual Pdf

May 20, 2010 8:11 PM
 

Dallas Maverick Coaches, List Megaman X Mavericks said:

Pingback from  Dallas Maverick Coaches, List Megaman X Mavericks

May 21, 2010 2:03 PM
 

Murano Msrp, Axxess Model Se Nissan Murano said:

Pingback from  Murano Msrp, Axxess Model Se Nissan Murano

May 21, 2010 6:21 PM
 

Saratoga Hair Replacement, Saratoga Rose Inn Reviews said:

Pingback from  Saratoga Hair Replacement, Saratoga Rose Inn Reviews

May 21, 2010 8:38 PM
 

1999 Bmw 328i Colors, 328i Headlight Marketing Bmw 320d said:

Pingback from  1999 Bmw 328i Colors, 328i Headlight Marketing Bmw 320d

May 22, 2010 3:46 AM
 

Avenger Door Handle Hammered Metal, 1997 Dodge Avenger Sale said:

Pingback from  Avenger Door Handle Hammered Metal, 1997 Dodge Avenger Sale

May 22, 2010 1:27 PM
 

Used Honda Parts Fort Collins, Honda Dealer Pa said:

Pingback from  Used Honda Parts Fort Collins, Honda Dealer Pa

May 22, 2010 5:12 PM
 

530i 2006 Bmw 330i, Replacement 2006 Bmw 330i Window Regulator - 419.luna-atra.net said:

Pingback from  530i 2006 Bmw 330i, Replacement 2006 Bmw 330i Window Regulator - 419.luna-atra.net

May 24, 2010 12:25 PM
 

Calculate Granada, Womens Granada Comfort - 5.binggreen.com said:

Pingback from  Calculate Granada, Womens Granada Comfort - 5.binggreen.com

May 24, 2010 5:13 PM
 

Xg300 Tube Kyb Gr 2, 300z Half - 111.mfbattle.com said:

Pingback from  Xg300 Tube Kyb Gr 2, 300z Half - 111.mfbattle.com

May 25, 2010 12:01 AM
 

1972 Chrysler Newport Custom Electronic Ignition, Mazda Dealer Newport - 119.renters.ws said:

Pingback from  1972 Chrysler Newport Custom Electronic Ignition, Mazda Dealer Newport - 119.renters.ws

May 25, 2010 4:59 PM
 

traffic travis discount said:

Pingback from  traffic travis discount

April 18, 2011 4:01 PM
Powered by Community Server (Commercial Edition), by Telligent Systems