private void WebView1_OnPermissionRequested(object sender, WebViewControlPermissionRequestedEventArgs e) { if (e.PermissionRequest.State == WebViewControlPermissionState.Allow) { return; } var msg = $"Allow {e.PermissionRequest.Uri.Host} to access {e.PermissionRequest.PermissionType}?"; var response = MessageBox.Show(msg, "Permission Request", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (response == MessageBoxResult.Yes) { if (e.PermissionRequest.State == WebViewControlPermissionState.Defer) { WebView1.GetDeferredPermissionRequestById(e.PermissionRequest.Id)?.Allow(); } else { e.PermissionRequest.Allow(); } } else { if (e.PermissionRequest.State == WebViewControlPermissionState.Defer) { WebView1.GetDeferredPermissionRequestById(e.PermissionRequest.Id)?.Deny(); } else { e.PermissionRequest.Deny(); } } }