-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExample1.ps1
30 lines (25 loc) · 1.09 KB
/
Example1.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
###########
# Learn how to build Material Design based PowerShell apps
# --------------------
# Example1: Hello World
# --------------------
# Avi Coren (c)
# Blog - https://www.materialdesignps.com
# Github - https://github.com/DrHalfBaked/PowerShell.MaterialDesign
# LinkedIn - https://www.linkedin.com/in/avi-coren-6647b2105/
#
[Void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[Void][System.Reflection.Assembly]::LoadFrom("$PSScriptRoot\Assembly\MaterialDesignThemes.Wpf.dll")
[Void][System.Reflection.Assembly]::LoadFrom("$PSScriptRoot\Assembly\MaterialDesignColors.dll")
try {
[xml]$Xaml = (Get-content "$PSScriptRoot\Example1.xaml")
$Reader = New-Object System.Xml.XmlNodeReader $Xaml
$Window = [Windows.Markup.XamlReader]::Load($Reader)
}
catch {
Write-Error "Error building Xaml data.`n$_"
exit
}
$Xaml.SelectNodes("//*[@Name]") | ForEach-Object { Set-Variable -Name ($_.Name) -Value $Window.FindName($_.Name) -Scope Script }
$Btn1.Add_Click({$TxtBox2.Text = $TxtBox1.Text})
$Window.ShowDialog() | out-null