Example #1
0
        public void OnSource_Ensure_ButtonClicked(object sender, RoutedEventArgs args)
        {
            if (_wv2_ConcurrentCreation != null)
            {
                // We'll call EnsureCWV2() in this special CWV2Initialized Handler
                _wv2_ConcurrentCreation.CoreWebView2Initialized += OnCoreWebView2Initialized_Ensure;

                // Set Source #1
                WebView2Common.NavigateToUri(_wv2_ConcurrentCreation, WebView2Common.GetTestPageUri("SimplePage.html"));
            }
        }
Example #2
0
        // Kick off Source1 (trigger creation), then Source2 while 1 is in progress
        public void OnSource_Source_ButtonClicked(object sender, RoutedEventArgs args)
        {
            if (_wv2_ConcurrentCreation != null)
            {
                // We'll set Source #2 in this special CWV2Initialized Handler
                _wv2_ConcurrentCreation.CoreWebView2Initialized += OnCoreWebView2Initialized_Source;

                // Set Source #1 and attach  special CoreWebView2Initialized handler to apply Source #2 at that time
                WebView2Common.NavigateToUri(_wv2_ConcurrentCreation, WebView2Common.GetTestPageUri("SimplePage.html"));
            }
        }
Example #3
0
        public void OnGood_Source_ButtonClicked(object sender, RoutedEventArgs args)
        {
            if (_wv2_CoreProcessFailed != null)
            {
                try
                {
                    WebView2Common.NavigateToUri(_wv2_CoreProcessFailed, WebView2Common.GetTestPageUri("SimplePage.html"));
                }
                catch (Exception e)
                {
                    SetClosedExceptionCount(_closedExceptionCount + 1);

                    string s = string.Format("{0} Caught exception: {1}", _wv2_CoreProcessFailed.Name, e.ToString());
                    _helpers.AppendMessage(s);
                    Status2.Text = Status2.Text + " " + s;
                }
            }
        }
Example #4
0
        private void OnBadSourceButtonClickedHelper(string badUri)
        {
            if (_wv2_CoreProcessFailed != null)
            {
                try
                {
                    WebView2Common.NavigateToUri(_wv2_CoreProcessFailed, new Uri(badUri));
                }
                catch (Exception e)
                {
                    SetClosedExceptionCount(_closedExceptionCount + 1);

                    string s = string.Format("{0} Caught exception: {1}", _wv2_CoreProcessFailed.Name, e.ToString());
                    _helpers.AppendMessage(s);
                    Status2.Text = Status2.Text + " " + s;
                }
            }
        }
Example #5
0
        public void OnSetSource_OfflineElement_ButtonClicked(object sender, RoutedEventArgs args)
        {
            if (_wv2_Programmatic_Offline != null)
            {
                try
                {
                    Uri newUri = WebView2Common.GetTestPageUri("SimplePage.html");
                    _wv2_Programmatic_Offline.Source = newUri;
                }
                catch (Exception e)
                {
                    SetClosedExceptionCount(_closedExceptionCount + 1);

                    string s = string.Format("{0} Caught exception: {1}", _wv2_Programmatic_Offline.Name, e.ToString());
                    _helpers.AppendMessage(s);
                    Status2.Text = Status2.Text + " " + s;
                }
            }
        }
Example #6
0
        public void OnCreate_MarkupElement_Source_ButtonClicked(object sender, RoutedEventArgs args)
        {
            if (_wv2_Markup != null)
            {
                _wv2_Markup.Close();
                RemoveWebViewEventHandlers(_wv2_Markup);
            }

            string uriString = WebView2Common.GetTestPageUri("SimplePage.html").ToString();

            var myWebView = (WebView2)XamlReader.Load(@"
                <controls:WebView2 xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                          xmlns:controls='using:Microsoft.UI.Xaml.Controls'
                          xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                          x:Name='_wv2_Markup'
                          Source='" + uriString + @"'/>");

            AddWebViewEventHandlers(myWebView);
            _wv2_Markup = myWebView;
            WebView2_Container3.Child = _wv2_Markup;
        }
Example #7
0
 public WebView2CoreObjectsPage()
 {
     InitializeComponent();
     _helpers = new WebView2Common(this);
     Loaded  += Page_Loaded;
 }
Example #8
0
 // Set Source from OnCoreWebView2Initialized handler (for ConcurrentCreationRequestsTest)
 private void OnCoreWebView2Initialized_Source(WebView2 sender, object args)
 {
     sender.CoreWebView2Initialized -= OnCoreWebView2Initialized_Source; // Don't spin creation on next CWV2Initialized!
     WebView2Common.NavigateToUri(sender, WebView2Common.GetTestPageUri("SimplePageWithButton.html"));
 }