It’s been three posts since we’ve showered, and our XAML is starting to smell a bit. It’s time to practice some good hygiene. Thus far we’ve just dragged elements into our window and resized by hand. For the most part that has worked, up until we ran our last example. Our loon didn’t expand to the entire window and left some gross white space on the right side we need to scrub off. I said this in my MMS presentation, and I’ll say it again:
Alrighty, so now we know how to create a window and make a button do something. What about media like images and sounds? In C# you might embed the resource (image/sound) directly in your executable and reference it via an internal path reference. In PowerShell though, short of converting the file to a base-64 value there isn’t a really good way to store file content directly in your script. Nor should there be.
Today we’ll kick off Part 2 of the series on building WPF GUIs with the PowerShell Presentation Framework. We’re still in the beginning phases of our GUI building learning, so things will still be simple. I hope you kept a copy of your XAML from last time (the one where we created a label and a button). If you didn’t - here’s a solution you can launch in Visual Studio that has everything we need for today.