Search code examples
c#windows-phone-8windows-phone-8.1

Open URL in default Web Browser. Windows Phone 8.0 app


I have a hyperlink inside a Text block. I want it to open the link int he web browser, but when I Click it I get a popup saying

"Search an app in the store"

and my app crashes.....

my XAML code is:

<TextBlock HorizontalAlignment="Right" Height="49" Margin="0,0,10,0" TextWrapping="Wrap" Width="326" Foreground="Black" FontSize="16">
                    <TextBlock.Inlines>
                        <Hyperlink Click="Hyperlink_Click" NavigateUri="www.bing.com">
                            <Hyperlink.Foreground>
                                <ImageBrush Stretch="Fill" ImageSource="Assets/Proceed.png"/>
                            </Hyperlink.Foreground>Don't have a Selfcare Account ? Register here.</Hyperlink>
                    </TextBlock.Inlines>
                    <!--<Hyperlink xml:space="preserve" Foreground="#000" FontSize="16">Don't have a Mobitel Selfacre Account ? Register here. </Hyperlink>-->
                </TextBlock>

my CS code is:

private async void Hyperlink_Click(Windows.UI.Xaml.Documents.Hyperlink sender, Windows.UI.Xaml.Documents.HyperlinkClickEventArgs args)
        {
            await Launcher.LaunchUriAsync(new Uri("www.google.com"));

        }

Kindly help me fix it... Any kind of help is appreciated....


Solution

  • Change the uri from www.bing.com to http://www.bing.com. It needs the protocol to determine the application it uses to start the url with.

    Check these links for more information: