【发布时间】:2013-03-06 21:06:50
【问题描述】:
我正在尝试导航到 URL,但 Web 浏览器控件显示空白页或显示找不到页面错误。这是我的代码:
Private Sub qwb_Loaded(sender As Object, e As RoutedEventArgs) Handles qwb.Loaded
NavigationContext.QueryString.TryGetValue("url", url)
Dim urltonav = New Uri(url, UriKind.RelativeOrAbsolute)
qwb.Navigate(urltonav)
End Sub
PS:网址是http://www.mobile.quora.com。在 Page1_Loaded 事件下加载页面也不起作用。
这是具有 Web 浏览器控件的页面的 XAML 代码:
<phone:PhoneApplicationPage
x:Class="MyApp.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="12,17,0,28"/>
<phone:WebBrowser x:Name="qwb" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2" Height="768" Width="480" IsScriptEnabled="True"/>
</Grid>
</phone:PhoneApplicationPage>
我正在尝试在设备上运行该应用程序,而不是在具有工作 WiFi 的模拟器上运行。操作系统版本是 Windows Phone 8,我有 Visual Studio 2012。我认为网络没有问题。我什至尝试使用 .Source 属性而不是 Navigate 但它也不起作用。
【问题讨论】:
-
该 URL 在桌面和 WP8 设备上的 IE 上都失败(找不到 404)。为什么你希望它在代码中工作?
标签: vb.net xaml windows-phone-8 webbrowser-control windows-phone