Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding hyperlink button in XAML with Visual Studio 11 (Windows 8)

I need to add a hyperlink button that directs to a webpage to my metro style apps written with C# and XAML. As in Silverlight, there is no NavigateURI option. Is there any other option to make a hyperlink redirect to a specific webpage?

like image 886
janani Avatar asked Mar 31 '26 16:03

janani


1 Answers

There's a sample in the Sample App Pack that does this.

    // Launch a URI.
    private async void LaunchUriButton_Click(object sender, RoutedEventArgs e)
    {
        // Create the URI to launch from a string.
        var uri = new Uri(uriToLaunch);

        // Launch the URI.
        bool success = await Windows.System.Launcher.LaunchUriAsync(uri);
        if (success)
        {
            rootPage.NotifyUser("URI launched: " + uri.AbsoluteUri, NotifyType.StatusMessage);
        }
        else
        {
            rootPage.NotifyUser("URI launch failed.", NotifyType.ErrorMessage);
        }
    }
like image 114
Michael Avatar answered Apr 03 '26 16:04

Michael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!