Created
August 31, 2016 07:31
-
-
Save alexinnes/12c6dd0461399ac35fb29e36f00c98ab to your computer and use it in GitHub Desktop.
Outline for creating GUIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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