private void NavigationBackward(object sender, RoutedEventArgs e) { if (WebViewContent.CanGoBack) { WebViewContent.GoBack(); } }
private void NavigationForward(object sender, RoutedEventArgs e) { if (WebViewContent.CanGoForward) { WebViewContent.GoForward(); } }
private void HrefLocationTextBox_KeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) // enter key pressed, load new page { try { if (Uri.IsWellFormedUriString(HrefLocationTextBox.Text, UriKind.RelativeOrAbsolute) && /* make sure there is a '.' between domain name and top level domain (e.g. ".com") */ HrefLocationTextBox.Text.Contains('.')) { // construct new URI Uri uri = new UriBuilder(HrefLocationTextBox.Text).Uri; // load page WebViewContent.Navigate(uri); // remove focus from TextBox and set focus on WebView WebViewContent.Focus(FocusState.Programmatic); } else { // url is not valid, search on Google instead Uri uri = new Uri($"https://www.google.com/search?q={Uri.EscapeDataString(HrefLocationTextBox.Text)}"); // load page WebViewContent.Navigate(uri); // remove focus from TextBox and set focus on WebView WebViewContent.Focus(FocusState.Programmatic); } } catch (Exception err) { // reset href location text box HrefLocationTextBox.Text = ""; } } }
private void RefreshButton_Click(object sender, RoutedEventArgs e) { // determine action based on current symbol icon if (RefreshSymbol.Symbol == Symbol.Refresh) { WebViewContent.Refresh(); } else if (RefreshSymbol.Symbol == Symbol.Cancel) { WebViewContent.Stop(); } }