Skip to content

Instantly share code, notes, and snippets.

@fukuroder
Last active August 30, 2015 14:00
Show Gist options
  • Select an option

  • Save fukuroder/afcacdaa48c8cedf56dd to your computer and use it in GitHub Desktop.

Select an option

Save fukuroder/afcacdaa48c8cedf56dd to your computer and use it in GitHub Desktop.
XAML in Windows PowerShell
Add-Type -AssemblyName presentationframework
[xml]$xaml = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="100" Width="200" ResizeMode="NoResize">
<Grid>
<Button Name="button1" Content="XAML"/>
</Grid>
</Window>
'@
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$window=[Windows.Markup.XamlReader]::Load( $reader )
$button = $window.FindName("button1")
$button.add_Click({ $window.Close() })
$window.ShowDialog() | out-null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment