1

The mailto link doesn't work in this sample:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <TextBlock>Please email
        <Hyperlink NavigateUri="mailto:test@test.co.uk">test@test.cp.uk</Hyperlink>
    </TextBlock>
</Window>

It works if I change Window to UserControl.

Can anyone help?

Keith Harrison
  • 1,567
  • 14
  • 22
  • You might want to take a look at this question: http://stackoverflow.com/questions/1963532/how-to-get-a-simple-hyperlink-to-work-in-xaml – Gerrit Fölster Feb 19 '14 at 13:08
  • Have a look on this too : http://stackoverflow.com/questions/10238694/example-using-hyperlink-in-wpf – Sankarann Feb 19 '14 at 13:12

1 Answers1

7

In Xaml : You need to add RequestNavigate

                    <TextBlock >
                        Please email <Hyperlink NavigateUri="mailto:test@test.co.uk"  RequestNavigate="Hyperlink_RequestNavigate">test@test.cp.uk</Hyperlink>
                    </TextBlock>

In code behind :

    private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
    {
        Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
        e.Handled = true;
    }