Open url by clicking a button #17354
-
Hello everyone! As the title implies, I want to add a button to my app that opens a url. Normally I would use the HyperlinkButton-Control, but I don't like its visual appearance (it does not look like a button). I tried making it look like a button by putting it in a Border-Control, unfortunately this does not make the whole Border clickable and I am not able to change the HyperlinkButton's appearance, since changing its Foreground-Property does not change the text color (Issue?). Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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
} |
Beta Was this translation helpful? Give feedback.
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: