title: Bind WebView2 to ViewModel Using Caliburn Micro
body: <p>I am using the guide located her for reference: <a href="https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/wpf" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/wpf</a></p>
  <p>Utilizing that guide, I was able to get WebView2 started within my application. Now I am trying to seperate the code into a ViewModel as I will have many more elements on that page. The application as a whole uses Caliburn Micro. I am able to bind everything to the ViewModel except for the WebView2 itself. Wheneer I Select the Go button it states that the WebView is null. I tried manually setting the WebView however that does not work.</p>
  <p>BrowserView.xaml:</p>
  <pre><code>    &lt;Button 
              x:Name=&quot;ButtonGo&quot; 
              Content=&quot;Go&quot;
              /&gt;
          &lt;TextBox x:Name = &quot;Addressbar&quot;
                   /&gt;
      &lt;wv2:WebView2 x:Name = &quot;WebView&quot;
                    Source=&quot;{Binding WebViewSource}&quot;
  /&gt;
  </code></pre>
  <p>BrowserViewModel.cs</p>
  <pre><code>        private WebView2 _webView;
  
      public WebView2 WebView
      {
          get 
          {
              return _webView; 
          }
          set 
          {
              _webView = value;
              NotifyOfPropertyChange(() =&gt; WebView);
          }
      }
  
      public string WebViewSource { get; set; } = &quot;http://Google.com&quot;;
  
      private string _addressbar;
  
      public string Addressbar
      {
          get 
          { 
              return _addressbar; 
          }
          set 
          { 
              _addressbar = value;
              NotifyOfPropertyChange(() =&gt; Addressbar);
          }
      }
  
  
      public void ButtonGo()
      {
          if (WebView != null &amp;&amp; WebView.CoreWebView2 != null)
          {
              WebView.CoreWebView2.Navigate(&quot;https://bing.com&quot;);
          }
      }
  </code></pre>
  <p>No matter what I try WebView keeps coming back null and I am not able to change the page.</p>