private void OnNavigationStarting(object sender, WebViewControlNavigationStartingEventArgs args)
        {
            var handler = NavigationStarting;

            if (handler != null)
            {
                handler(this, args);
            }
        }
        private void OnFrameNavigationStarting(WebViewControlNavigationStartingEventArgs args)
        {
            var handler = FrameNavigationStarting;

            if (handler != null)
            {
                handler(this, args);
            }
        }
        private void OnNavigationStarting(IWebViewControl sender, Windows.Web.UI.WebViewControlNavigationStartingEventArgs args)
        {
            var newNavigationRequested = false;
            var cancelRequested        = false;

            try
            {
                var url = args.Uri;

                // The NavigatingToAboutBlank property indicates whether we are navigating to "about:blank" as a result of navigating
                // to a null source, or stream/string navigation.
                // We set the NavigatingToAboutBlank bit to true in the void Navigate(Uri) method. When the above conditions are true,
                // the NavigatingToAboutBlank is true and the source must be "about:blank"
                if (NavigatingToAboutBlank && url != null && url != new Uri("about:blank"))
                {
                    NavigatingToAboutBlank = false;
                }

                if (!NavigatingToAboutBlank && !Security.CallerHasWebPermission(url))
                {
                    cancelRequested = true;
                }
                else
                {
                    // When Source is set to null or navigating to stream/string, we navigate to "about:blank" internally.
                    // Make sure we pass null in the event args
                    if (NavigatingToAboutBlank)
                    {
                        url = null;
                    }

                    var a = new WebViewControlNavigationStartingEventArgs(args, url);

                    // Launching a navigation from the NavigationStarting event handler causes re-entrancy
                    var lastNavigation = LastNavigation;

                    // Fire navigating event
                    OnNavigationStarting(a);

                    if (LastNavigation != lastNavigation)
                    {
                        newNavigationRequested = true;
                    }

                    cancelRequested = a.Cancel;
                }
            }

            // Disable to suppress FXCop warning since we really do want to catch all exceptions
#pragma warning disable 6502
            catch
            {
                cancelRequested = true;
            }
#pragma warning restore 6502
            finally
            {
                if (cancelRequested && !newNavigationRequested)
                {
                    CleanInternalState();
                }

                if (cancelRequested || newNavigationRequested)
                {
                    args.Cancel = true;
                }
            }
        }