title: How to properly import XAML code to Powershell
body: <p>I'm trying to use a VisualStudio-created GUI in Powershell.</p>
  
  <p>Therefore I have to import the XAML code from VisualStudio into my script</p>
  
  <p>Here's what I got so far:</p>
  
  <pre><code>[xml]$XAML = @"
  &lt;Window 
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      &lt;Grid Margin="0,0,2,0"&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="0*"/&gt;
              &lt;ColumnDefinition/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Label Name="Enter_Hostname_Label" Content="Enter Hostname:" HorizontalAlignment="Left" Height="26" Margin="9,19,0,0" VerticalAlignment="Top" Width="98" Grid.Column="1"/&gt;
          &lt;TextBox Name="Textbox" HorizontalAlignment="Left" Height="21" Margin="15,43,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="119" Grid.Column="1"/&gt;
          &lt;Label Name="Available_Hostnames_Label" Content="Available Hostnames:" HorizontalAlignment="Left" Height="26" Margin="11,83,0,0" VerticalAlignment="Top" Width="125" Grid.Column="1"/&gt;
          &lt;ListBox Name="Listbox" Grid.ColumnSpan="2" HorizontalAlignment="Left" Height="141" Margin="15,108,0,0" VerticalAlignment="Top" Width="119"/&gt;
          &lt;Button Name="Continue_Button" Grid.ColumnSpan="2" Content="Continue" HorizontalAlignment="Left" Height="21" Margin="143,108,0,0" VerticalAlignment="Top" Width="84" Click="Button_Click"/&gt;
          &lt;Button Name="Search_Button" Grid.ColumnSpan="2" Content="Search" HorizontalAlignment="Left" Height="21" Margin="143,43,0,0" VerticalAlignment="Top" Width="84" Click="Button_Click"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt; 
  "@ 
  
  [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
  try{
     $Form=[Windows.Markup.XamlReader]::Load( (New-Object System.Xml.XmlNodeReader $XAML) )
  } catch {
     Write-Host "Windows.Markup.XamlReader konnte nicht geladen werden. Mögliche Ursache: ungültige Syntax oder fehlendes .net"
  }
  #Fenster anzeigen:
  $Form.ShowDialog()
  </code></pre>
  
  <p>But I get an error message that says:
  The Value can't be converted to the type "System.Xml.XmlDocument". Error: "A name isn't allowed to start with the sign '&lt;', hexadecimal value 0x3C</p>
  
  <p>But I can't change this since the GUI code wouldn't work anymore if I do so</p>
  
  <p>I searched a lot on the internet but couldn't find a solution. It seems to work for everyone like this</p>
  
  <p>Can someone tell me what's wrong with my script?</p>