Skip to content

Instantly share code, notes, and snippets.

@alexinnes
Created August 31, 2016 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexinnes/12c6dd0461399ac35fb29e36f00c98ab to your computer and use it in GitHub Desktop.
Save alexinnes/12c6dd0461399ac35fb29e36f00c98ab to your computer and use it in GitHub Desktop.
Outline for creating GUIs
#Add XAML code inbetween the two @
$inputXML = @"
"@
$inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = $inputXML
#Read XAML
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
catch{Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."}
$xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name "WPF_$($_.Name)" -Value $Form.FindName($_.Name)}
#ADD Your Function here, add NAME tag to XAML and use WPF_NAME as the function
#show the form
$Form.ShowDialog() | out-null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment