Add-Type -AssemblyName PresentationFramework, PresentationCore, WindowsBase, System.Windows.Forms # --- THE CLEANING FUNCTION --- # This makes it easy to load any XAML you copy from Visual Studio function Load-VisualStudioXaml { param([string]$RawXaml) $Cleaned = $RawXaml -replace 'mc:Ignorable="d"','' ` -replace "x:Class.*?[^\x20]*",' ' ` -replace "xmlns:local.*?[^\x20]*",' ' ` -replace 'd:ItemsSource=".*?"',' ' ` -replace 'd:SampleData=".*?"',' ' ` -replace 'd:DesignHeight=".*?"',' ' ` -replace 'd:DesignWidth=".*?"',' ' [xml]$xml = $Cleaned $reader = New-Object System.Xml.XmlNodeReader $xml return [Windows.Markup.XamlReader]::Load($reader) } # --- SPLASH XAML --- $splashXML = @" "@ # --- MAIN XAML --- $mainXML = @"