WebView在Windows Phone 8.1 Universal Apps中第二次无法运行

时间:2015-06-18 06:19:06

标签: c# windows-runtime windows-phone-8.1

当我第二次导航到webview页面时,我的Windows Phone 8.1 Universal App崩溃了。我为每个事件都使用了try catch块,但是应用程序崩溃时抛出任何异常。我不知道发生了什么,请帮我纠正这个......

XAML代码:

  <WebView  VerticalAlignment="Top"                  
              Loaded="WBrowser_Loaded"
             HorizontalAlignment="Left"
             NavigationFailed="WBrowser_NavigationFailed" 
             Margin="0,0,0,0" Name="WBrowser"
             ScrollViewer.ZoomMode="Disabled"
             ScrollViewer.VerticalScrollBarVisibility="Disabled"
             Height="570" 
             Grid.Row="0"  Width="370"></WebView>

Cs代码:

 private void WBrowser_Loaded(object sender, RoutedEventArgs e)
 {
  try
   {
    WBrowser.Navigate(new Uri("http://www.youtube.com", UriKind.RelativeOrAbsolute));
   }
  catch(Exception ex)
   {

   }
 }

private void WBrowser_NavigationFailed(object sender, WebViewNavigationFailedEventArgs e)
{
    if (System.Diagnostics.Debugger.IsAttached)
    {
       // A navigation has failed; break into the debugger
       System.Diagnostics.Debugger.Break();
    }
}

0 个答案:

没有答案