What I Learned Porting .NETpad to … UWP? (Premium)

The Universal Windows Platform (UWP) isn’t particularly well-suited to traditional productivity applications. Naturally, I was curious how hard it would be to recreate my .NETpad application using this environment, given my previous efforts porting it to C# and then to WPF.

As I write this, I’ve only made a few basic first steps; this isn’t a fully functioning and complete application, as is the C# version (which utilizes Windows Forms, just like the original Visual Basic version). Nor is it as polished and far-along as is the WPF version, which I’ve stopped working on, at least for now.

Instead, this started as an experiment to determine whether the layout capabilities of UWP would let me recreate the Notepad user interface, albeit in a version that would seamlessly adapt to different display resolutions and dot-pitches, a key problem with the initial WinForms versions of the apps. Too, I was curious about UWP’s ability to adapt to dual-screen devices, as I’m planning an app-based version of the Windows 10 Field Guide that will work properly on Surface Neo and, perhaps, Surface Duo.

Anyway. I started really playing around with UWP for the first time recently.

And it is a mess.

Granted, UWP wasn’t designed to work well with an app like .NETpad. If you ever experimented with Store-based text editors during the Windows 8 or Windows 10 eras, you know that there are/were a lot of low-quality apps out there with giant, fingertip-friendly round buttons in giant toolbars and minimal configuration options. What I wanted was something recognizably Notepad, with a standard menu at the top and a status bar at the bottom. I just wanted it to adapt better to different display types and on-the-fly changes to the resolution, DPI, and orientation. Something that would work properly in Light mode or Dark mode. Something that respected Tablet mode. And so on.

And the basics are possible. Like WPF, UWP offers a variety of layout options via XAML (pronounced “Zammel”), the declarative XML-like markup language that Microsoft developers use to construct device-independent user interfaces. After experimenting with a few different layout panels, I ended up going with the simplest of all, the grid, which supports both multi-column and multi-row layouts.

Technically, I just need three rows: One for the menu bar, one for the text box, and one for the status bar. (I'm also using three columns, just to quickly space the items in the status bar for now.) UWP has MenuBar and TextBox controls, so those were easy enough. And while there’s no status bar, I figured I could roll my own using other controls. For now, I’m just using TextBoxes for the “status bar”-like bottom of the app as placeholders. The basic XAML (I’ve stripped a lot out) looks like so:
<Grid>
   <Grid.ColumnDefinitions>
       <ColumnDefinition Width="1*" />
       <ColumnDefinition Width="1*" />
       &...

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