8Apr
Launch Internet Explorer from HyperlinkButton in Windows 8 Metro app
Posted by admin | Category: Metro, Windows 8 | 5 Comments
If you are building a Metro app for Windows 8 with XAML/C# and need to launch your link in a browser, there is HyperlinkButton control but you need to wire up the Click event and launch it from the codebehind file.
So I ended up doing something like this
1: <HyperlinkButton
2: x:Name="Readmore"
3: Click="Readmore_OnClick"
4: Tag="{Binding Link}"
5: Content="Read more.." />
I am using the Tag property to bind my link and get it in the code like this.
1: private void Readmore_OnClick(object sender, RoutedEventArgs e)
2: {
3: var link = (HyperlinkButton) e.OriginalSource;
4: Windows.System.Launcher.LaunchUriAsync(new Uri(link.Tag.ToString()));
5: }
The above Launcher class can be used to load files stored locally on the device.

[...] TLDR Version: If you’ve used DataBinding in WPF or Silverlight, it is very familiar.”Launch Internet Explorer from HyperlinkButton in Windows 8 Metro app (Zubair Ahmed)“If you are building a Metro app for Windows 8 with XAML/C# and need to launch [...]
Finally figured out correct syntax for a JavaScript hyperlink:
<a href=”#” data-win-bind=”href: linkUrl; textContent: linkUrl”></a>
Thanks for the help!
Thanks a ton man !! I needed it real quick !!
Thanks a ton, was stuck looking for a code-based solution!