Can PowerShell be used as code behind for WPF
-
22-08-2019 - |
Question
We can use [Windows.Markup.XamlReader]::Load to load XAML file in PowerShell, but is there some way to specify some PowerShell script as code behind?
Solution
Now there is also WPK, in the PowerShellPack which makes creating WPF UI in PowerShell extremely straightforward and fun.
OTHER TIPS
PowerShell can be used to provide functionality in a WPF application. Check out these great blog posts regarding using PowerShell and WPF...
HuddledMasses.Org - PowerBoots - a WPF GUI Toolkit for PowerShell
PowerBoots - Shoes for PowerShell
PowerBoots - Loading XAML Windows in PowerShell 1.0 or 2.0
Windows PowerShell Team Blog
http://blogs.msdn.com/powershell/archive/2008/05/25/powershell-and-wpf-wtf.aspx
WPF & PowerShell – Part 1 ( Hello World & Welcome to the Week of WPF )
WPF & PowerShell – Part 2 (Exploring WPF (and the rest of .NET) with Scripts)
WPF & PowerShell -- Part 3 (Handling Events)
WPF & PowerShell -- Part 4 (XAML & Show-Control)
WPF & PowerShell - Part 5 ( Using WPF & PowerShell Modules)
WPF & PowerShell - Part 6 (Running Functions in the Background)
While I don't know for sure, I would guess not. Given that Visual Studio only exposes C# and VB as languages to use to build WPF applications, that implies that work needs to be done at the tool level in order to add support for WPF to a language. Since a .NET language doesn't get WPF support "for free", it's doubtful that PowerShell has the ability to be the code behind for a WPF UI.
The current place to look at is http://showui.codeplex.com/SourceControl/list/changesets.
Sorry Show-UI has no release yet. It is the successor to PowerBoots and WPK.