title: Xamarin Forms - Run a hidden WebView without attaching it to the view
body: <p>Currently my code creates an instance of a hidden class and initializes a WebView that should download JavaScript from the server. The problem is that if the WebView is not part of the main screen that the user is looking at, it doesn't load the URL. </p>
  
  <p>My Simple App: </p>
  
  <pre><code>public partial class App : Application
  {
      // set up Hidden WebView
      CompanySDK.FooClass foo = new CompanySDK.FooClass();
  
      public App()
      {
          InitializeComponent();
  
          var page = new ContentPage();
  
          page = new DemoAppPage();
  
          MainPage = page;
      }
  
      protected override void OnStart()
      {
          // test a method call
          foo.test();
      }
  }
  </code></pre>
  
  <p>Hidden WebView Class: </p>
  
  <pre><code>public class FooClass
  {
      WebView browser = new WebView();
  
      public FooClass()
      {
          browser.Source = "https://companyserver.com/xyz";
  
          // make the browser invisible
          browser.SetValue(IsVisibleProperty, false);
  
          System.Diagnostics.Debug.WriteLine("WebView Started for platform: " + Device.OS.ToString().ToLower());
  
      }
  
      public void test()
      {
          System.Diagnostics.Debug.WriteLine("Test Method ");
  
          String js = "alert('Test Method');";
          browser.Eval(js);
      }
  
  }
  </code></pre>
  
  <p>If I change <code>FooClass</code> to be a <code>ContentPage</code> and add it as the main app view, I see calls to <code>companyserver.com</code>, but I can't have the WebView as part of the UI, as it should remain in the background / hidden. My debug prints show up in all cases, so I know the code is being called. </p>
  
  <p>Is there a way to achieve what I'm after? </p>