When I run this and click on the link, I would expect a browser to open and it go to google, but nothing happens:
<Window x:Class="TestHyperlink2343.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <TextBlock> You and read this or <Hyperlink NavigateUri="http://www.google.com">go to google</Hyperlink> etc. </TextBlock> </Grid> </Window> So then I replace the above code with the following and still nothing happens. However, surprisingly, if I right click on the link, it goes to google:
<Window x:Class="TestHyperlink2343.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <TextBlock> You and read this or <Hyperlink MouseDown="Hyperlink_MouseDown">go to google</Hyperlink> etc. </TextBlock> </Grid> </Window> private void Hyperlink_MouseDown(object sender, MouseButtonEventArgs e) { System.Diagnostics.Process.Start("http://www.google.com"); } Why don't these examples work as expected and how can I get a simple hyperlink to work as users are accustomed to them working in web browsers (left click, open browser, go to site)?
Addendum
I solved this by creating my own hyperlink without the Hyperlink element like this:
<TextBlock Text="More info at wikipedia" TextDecorations="Underline" MouseDown="TextBlock_MouseDown_Wikipedia"/> private void TextBlock_MouseDown_Wikipedia(object sender, System.Windows.Input.MouseButtonEventArgs e) { System.Diagnostics.Process.Start("http://www.wikipedia.com"); } Strange that hyperlink doesn't work this easily.