I am wondering why my webbrowser doesn’t redirect to my html page.
I have a linkbutton on my xaml page with a tap event and i’m creating my object webbrowser when i load first the page.
This is the code I am using :
private void web_Tap(object sender, GestureEventArgs e)
{
wbbrowser.Navigate(new Uri("http://mywebsite.com/index.html", UriKind.Absolute));
}
This is the Xaml i am using :
<controls:PanoramaItem Header="about me">
<!--Double line list with text wrapping-->
<StackPanel Margin="0,0,0,17" Width="432" Height="483" >
<Rectangle Height="186" Width="150" Margin="-250,0,9,10" >
<Rectangle.Fill>
<ImageBrush ImageSource="Img/id.jpg"></ImageBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Text ="Name" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="age" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="nationality" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="adress" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="phone" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="email" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="others" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<HyperlinkButton Name="web" Content="web version" Margin="12,-6,12,10" Tap="web_Tap"></HyperlinkButton>
</StackPanel>
</controls:PanoramaItem>
So I am actually not declaring the Phone:WebBrowser.
I just create my object at the main page loaded .
First, you are using the HyperlinkButton the wrong way. You need to add a
TargetName="NAME_OF_TARGET"for it to navigate. Second, use theNavigateUriproperty to navigate to a page instead of handling the tap.This has been described in the MSDN documentation article.