Skip to content

Open url by clicking a button #17354

Discussion options

You must be logged in to vote

Hey @Zerachiel01,

for opening a link with a regular Button, you can use the URI Launcher from Windows.System and use Click or bind it to a Command, example:

<Button Click="LaunchWebsiteButtonAsync_Click" Content="Launch" />
private async void LaunchWebsiteButtonAsync_Click(object sender, RoutedEventArgs e)
{
    if(Uri.TryCreate(LaunchUriText, UriKind.Absolute, out var uri))
	{
		await Launcher.LaunchUriAsync(uri);
	}
	
	//error
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Zerachiel01
Comment options

@morning4coffe-dev
Comment options

Answer selected by jeromelaban
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants