private void ShowInAppBrowser(string url) { Uri loc = new Uri(url, UriKind.RelativeOrAbsolute); Deployment.Current.Dispatcher.BeginInvoke(() => { if (browser != null) { //browser.IsGeolocationEnabled = opts.isGeolocationEnabled; browser.Navigate2(loc); } else { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { PhoneApplicationPage page = frame.Content as PhoneApplicationPage; string baseImageUrl = "Images/"; if (page != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { browser = new WebBrowser(); browser.IsScriptEnabled = true; browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted); browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating); browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed); browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated); browser.Navigate2(loc); if (StartHidden) { browser.Visibility = Visibility.Collapsed; } //browser.IsGeolocationEnabled = opts.isGeolocationEnabled; grid.Children.Add(browser); } ApplicationBar bar = new ApplicationBar(); bar.BackgroundColor = Colors.Gray; bar.IsMenuEnabled = false; backButton = new ApplicationBarIconButton(); backButton.Text = "Back"; backButton.IconUri = new Uri(baseImageUrl + "appbar.back.rest.png", UriKind.Relative); backButton.Click += new EventHandler(backButton_Click); bar.Buttons.Add(backButton); fwdButton = new ApplicationBarIconButton(); fwdButton.Text = "Forward"; fwdButton.IconUri = new Uri(baseImageUrl + "appbar.next.rest.png", UriKind.Relative); fwdButton.Click += new EventHandler(fwdButton_Click); bar.Buttons.Add(fwdButton); ApplicationBarIconButton closeBtn = new ApplicationBarIconButton(); closeBtn.Text = "Close"; closeBtn.IconUri = new Uri(baseImageUrl + "appbar.close.rest.png", UriKind.Relative); closeBtn.Click += new EventHandler(closeBtn_Click); bar.Buttons.Add(closeBtn); page.ApplicationBar = bar; bar.IsVisible = !StartHidden; AppBar = bar; page.BackKeyPress += page_BackKeyPress; } } } }); }