title: Creating a Window in PowerShell using WPF
body: <p>I just start to understand slowly PowerShell, where I ended up with a problem to present a summary in a window. Someone suggested using WPF.</p>
  
  <p>Using WPF for the first time, I found some examples, I did use to experiment like the example below.</p>
  
  <pre><code>Clear-Host
  
  #Build the GUI
  
  [xml]$xaml = @"
  &lt;Window 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Name="Window" Title="Test Writing Results" WindowStartupLocation = "CenterScreen" ResizeMode="NoResize"
  Width = "1000" Height = "1000" ShowInTaskbar = "True" Background = "white"&gt; 
  &lt;StackPanel &gt;
      &lt;TextBlock x:Name = 'textblock' TextAlignment="Center"&gt;
          &lt;TextBlock.Inlines&gt;
          &lt;LineBreak /&gt;
              &lt;Run FontStyle="Italic" FontSize="36" Text="!!! Test Results !!!"&gt;
              &lt;Run.Foreground&gt;
                  &lt;LinearGradientBrush&gt;
                          &lt;GradientStop Color="Red" Offset="0.0" /&gt;
                          &lt;GradientStop Color="Orange" Offset="0.25" /&gt;
                          &lt;GradientStop Color="Yellow" Offset="0.5" /&gt;
                          &lt;GradientStop Color="Blue" Offset="0.75" /&gt;
                          &lt;GradientStop Color="Green" Offset="1" /&gt;
                      &lt;/LinearGradientBrush&gt;    
                  &lt;/Run.Foreground&gt;    
                 &lt;/Run&gt;
           &lt;/TextBlock.Inlines&gt;
      &lt;/TextBlock&gt;
      &lt;TextBlock TextWrapping = "Wrap"&gt;
           &lt;LineBreak /&gt;
              $b
           &lt;LineBreak /&gt;
      &lt;Run FontStyle="Italic" FontSize="16" Foreground="Blue" Text="     Question Nr:          Question Asked                              Your Answer" /&gt;
      &lt;/TextBlock&gt;
  &lt;/StackPanel&gt;
  &lt;/Window&gt;
  "@
  
  $reader=(New-Object System.Xml.XmlNodeReader $xaml)
  $Window=[Windows.Markup.XamlReader]::Load( $reader )
  
  #Connect to Controls
  $textblock = $Window.FindName('textblock')
  </code></pre>
  
  <p>I then tried to add some code to create a table. I found a nice example here:
  <a href="https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/how-to-define-a-table-with-xaml" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/how-to-define-a-table-with-xaml</a></p>
  
  <p>To my disappointment, I can't just copy this in-between lines and ended up with all kinds of error messages. I assume, the first issue is, that I need to add the correct assembly and also, not sure what else is needed?</p>
  
  <p>I only need a simple window with some text followed by a table. </p>
  
  <p>Can someone help, how I can do that?</p>