Ever wanted to create a cool user interfac? ISESteroids 184.108.40.206 now comes with WPF support (released May 11, 2015).
Here is how it works.
The beauty of WPF is the separation of design and form. Creating WPF user interfaces is almost like using HTML to design web pages. To start, create some XAML (which is a string-based UI definition).
In ISESteroids, right-click an empty spot in your editor, then choose “WPF”. The menu offers two editing options. Either use the light-weight and very fast “Kaxaml for ISESteroids” editor, or use Visual Studio. The latter requires VisualStudio to be installed (no express editions).
…and edit it!
Depending on the editor you chose, you can now design your user interface. In VisualStudio, you can open the toolbox, and drag UI elements such as buttons or textboxes onto your window.
Note that there is a full 2-way sync: whenever you save or run your XAML in VisualStudio, ISESteroids updates, too. And when you change the XAML in ISESteroids while VisualStudio is open, it updates as well.
“Kaxaml for ISESteroids” is a much faster, yet somewhat more limited editor. It does not support drag&drop, so you would need to know a bit of XAML to write and edit it. The result is visualized in its top pane. Kaxaml has a 1-way sync, so whenever you change something in Kaxaml, ISESteroids updates the PowerShell code.
Adding Code Behind
Once your XAML design meets your needs, close the XAML editor. Now, right-click the XAML definition in ISESteroids, choose “WPF”, and add the code behind.
This adds a PowerShell function that turns your XAML into a window object. To actually show the window, you would just need to add one more line:
To make your WPF window fly, you can access WPF events as well. Again, right-click the XAML definition in ISESteroids, choose “WPF”, then “Attach Events”.
A dialog opens and displays all named elements in a combo box (all WPF elements that you assigned a Name=”somename” attribute). Below, you can choose from the events, and when you do, ISESteroids adds the appropriate PowerShell event handlers to your code.
We’ll add more detailed tutorials, this is just a quick start.