The WPF Files: The End is Near (Premium)

I’m delighted---and more than a bit surprised---to discover that I’m almost done porting .NETpad to WPF and .NET Core. Honestly, I had expected this to drag out for another month or so, but I’ve made rapid progress.

Which is nice: I spent way more time on the original Windows Forms version of .NETpad than expected, though that project was also more successful than expected, and I did create two versions, one in Visual Basic and one in C#. Also, I’m eager to move on to even more modern frameworks and technologies.

My work porting .NETpad to C# earlier no doubt helped with this transition to WPF and .NET Core: Adding a third variable would no doubt have been disastrous. But I was still a bit surprised by how quickly I was able to plow through some of the functionality that I figured would be problematic. And some early setbacks---like the fonts issue I previously complained about---were quickly put aside.

Here, I’ll provide a few code comparison examples between the C#/Windows Forms/.NET Framework and C#/WPF/.NET Core versions of .NETpad. I realize the previous article was a bit code light---where the one before that was code-heavy, but without much in the way of context---but I’ve become so taken by the power of XAML that I just wanted to especially share that part of it.

And that, really, speaks to my evolving view of how I can handle these frameworks as I move forward. I originally figured that I’d write a different standalone app in WinForms, WPF, UWP, and whatever else I end up covering. But for the short term, adapting this existing and fully-functional app to each framework is perhaps the more interesting approach. Over time, of course, that will just become tedious. But as I noted in the previous article, embracing the special something that is central to each framework is appealing. And having an app to build off of eliminates some busy work and helps me get right to that.

For WPF (and UWP, I think), that special something is primarily XAML. And where creating custom dialogs in WinForms was both time-consuming and error-prone, doing so in WPF (and, I assume UWP) is almost fun. And since writing that previous article, I have created two more dialogs in XAML for the WPF version of .NETpad.

The first is the About box. Yes, you can add the WinForms About box, but as is the case with the Fonts dialog, I like the idea of creating a resolution/scaling-independent version myself. Plus, it was easy.

The only thing missing here is a bit of styling on the background, which should match the standard application background color (that is, not just be white); the text is programmatically updated at runtime.

The second is an Input box, which is used in several places in .NETpad---Find, Replace, and Replace All, for example---which was required because real InputBox is apparently unique to Visual Basic.

This one is cool because you can dynamically change the window title and (what I call the) Questio...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Please check our Community Guidelines before commenting

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC