Checkout the video tutorial and the less than 30 lines of code.
The Result
I built this WPF application using PowerShell and ShowUI. I used a single Url to get the data back from the Twitter API, sliced and diced the XML in PowerShell, used WPF Databinding, Templates, a Grid and ListBox (and a little more) to get this visual.
The Video
The Code
Import-Module ShowUI function Search-Twitter ($q = "PowerShell") { $wc = New-Object Net.Webclient $url = "http://search.twitter.com/search.rss?q=$q" ([xml]$wc.downloadstring($url)).rss.channel.item | select * } $ws = @{ WindowStartupLocation = "CenterScreen" SizeToContent = "Width" Height = 550 Title = "PowerShell, ShowUI and the Twitter API" } New-Window @ws -Show { ListBox -Background Black -ItemTemplate { Grid -Columns 55, 300 { Image -Name Image -Margin 5 -Column 0 TextBlock -Name Title -Margin 5 ` -Column 1 -TextWrapping Wrap -Foreground White } | ConvertTo-DataTemplate -binding @{ "Image.Source" = "image_link" "Title.Text" = "title" } } -DataContext {Search-Twitter PowerShell} ` -DataBinding @{ItemsSource="."} }



{ 4 trackbacks }
{ 4 comments… read them below or add one }
Hi,
How can we bind a PSObject using ShowUI?
thanks
Thiyagu
Thanks for the question Thiyagu.
New-Window -SizeToContent WidthAndHeight -DataContext { New-Object psobject -Property @{ name ="Jon" age = 10 } } -Show { UniformGrid -Columns 1 { TextBox -IsReadOnly -Margin 5 -DataBinding @{Text= New-Binding -Path name} TextBox -IsReadOnly -Margin 5 -DataBinding @{Text= New-Binding -Path age} } }Thank you Doug for that quick example, it works very nicely.
I did not know about ShowUI, until I read your post, and it looks amazing. Certainly looks much more cleaner than my output. I wrote script to get local trends so, maybe this time I will try to use ShowUI
This is an excellent example of how we can make it fun for folks, and get them more interested in Powershell.