Created
June 11, 2012 04:53
-
-
Save sunnyone/2908566 to your computer and use it in GitHub Desktop.
PowerShell XAML Example
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-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="20"> | |
<StackPanel> | |
<TextBox Name="textWeather" /> | |
<Button Name="buttonGet" Content="Get"/> | |
</StackPanel> | |
</Window> | |
'@ | |
$reader=(New-Object System.Xml.XmlNodeReader $xaml) | |
$window=[Windows.Markup.XamlReader]::Load( $reader ) | |
$textbox = $window.FindName("textWeather") | |
$button = $window.FindName("buttonGet") | |
$button_clicked = $button.add_Click | |
$button_clicked.Invoke({ | |
$proxy = New-WebServiceProxy -Uri http://www.webservicex.com/globalweather.asmx?WSDL | |
$textbox.Text = ([xml]$proxy.GetWeather('Tokyo', 'Japan')).CurrentWeather.SkyConditions | |
}) | |
$window.ShowDialog() | out-null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment