title: Webview2 WPF Windows 10 - Custom Source URL with parameters, possible?
body: <p>I spent the night trying to solve this problem but couldn't unfortunately. Please show mercy, since I am not proficient in C#.</p>
  <p>My MainWindow.xaml is pretty much from the MS support pages:</p>
  <pre><code>    &lt;Window x:Class=&quot;TrayApp.MainWindow&quot;
          xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
          xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
          xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
          xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
          xmlns:wv2=&quot;clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf&quot;
          xmlns:r=&quot;clr-namespace:System;assembly=mscorlib&quot;
          xmlns:local=&quot;using:clr-namespace:TrayApp&quot;
          Title=&quot;MainWindow&quot; Height=&quot;825&quot; Width=&quot;500&quot; 
          Deactivated=&quot;Window_Deactivated&quot;
          ShowInTaskbar=&quot;False&quot; 
          WindowStyle=&quot;None&quot;&gt;
      
          &lt;DockPanel&gt;
              &lt;wv2:WebView2 Name=&quot;webView&quot;
                    Source = &quot;https://website.com&quot; /&gt;
          &lt;/DockPanel&gt;
      &lt;/Window&gt;
  </code></pre>
  <p>My goal is, whenever the webview2 control is launched the URL has to be dynamically changed to <a href="https://website.com/?param=hostname" rel="nofollow noreferrer">https://website.com/?param=hostname</a></p>
  <p>I know that its possible to get hostname of a PC via <code>Environment.GetEnvironmentVariable(&quot;COMPUTERNAME&quot;)</code> however, I tried very many variations data bindings and other tricks, but nothing seems to work. Hopefully someone someone can help.</p>
  <p><strong>UPDATE:</strong>
  Thanks to Klaus Gütters suggestion, it made click in my head and it works as intended now!</p>
  <p>My MainWindow.xaml.cs looks like this:</p>
  <pre><code>public MainWindow()
          {
              InitializeComponent();
              this.Hide_Window();
              string host = Environment.GetEnvironmentVariable(&quot;COMPUTERNAME&quot;);
              webView.Source = new Uri(&quot;https://website.com/?param=&quot; + host);
  </code></pre>
  <p>And my MainWindow.xaml like this:</p>
  <pre><code>&lt;wv2:WebView2 x:Name=&quot;webView&quot;
                    Source = &quot;&quot;
  </code></pre>