michielpost.nl

Make e-mail address clickable in a Windows 8 metro app

17-07-2012

When creating an about page for your Windows 8 metro / WinRT application, you probably display your e-mail address so users can contact you.

It's easy to make your e-mail adress clickable. Just place your text inside a button control and handle the button click:

private async void MailButton_Click_1(object sender, RoutedEventArgs e)
{
// Create the URI to launch from a string.
var uri = new Uri("mailto:mymail@domain.com?subject=Subject of mail");

// Launch the URI.
bool success = await Windows.System.Launcher.LaunchUriAsync(uri);
}

The "mailto:" Uri will be launched, which will open the default e-mail application on the user's pc.

Tip: use the style "TextButtonStyle" to display the button as clickable text.

Comments


No comments yet.

New Comment

Name
E-mail (not published)
Comment
Enter the code shown: