.NETpad 2025: Building Out the Tabs (Premium)

Supporting tabs adds complexity to .NETpad, but I've successfully merged my backend code for that with a dynamic layout for the front-end. And fingers crossed, but it seems to be working as I push through all the commands and other methods that need to be updated. There's a lot to do, but this is an ideal time for some code refactoring and code quality improvements, and so I'm taking that on as well. Adding to the complexity, I've worked on so many different versions of this app over so much time that I've lost track of some of the changes I've made. But this was never going to be easy.

In the good news department, my initial bet on easing into this design seems to be paying off. As you may recall, towards the end of the previous phase of this app modernization, I added a major graphical change in the form of a customized title bar area and a basic code-based foundation for multiple documents in the form of an early version of the DocumentTab class (which I've subsequently updated, as expected). My hope was that these changes would make the transition to the coming tabs-based UI and multiple document support easier.

As described in the next two sections, my hopes were largely realized: Thanks to the UI changes, replacing the original title bar design with one that supports tabs was relatively straightforward (once I spent a few months determining what compromises WPF would force me to make), and the basic support for DocumentTab in code helped too, though the complexity of managing multiple documents was (and is) still daunting. There's just so much to keep track of.

So let's hit on both of these areas.
Updating the app UI for tabs
In .NETpad 3.0 for Windows 11, I created a custom title bar area for the app in anticipation of building out the tabs-based UI that I'm now implementing. Basically, it's a top Row in the Grid that forms the foundation for the main app window's user interface that consists of 7 Columns from left-to-right: A Back button (which is hidden in that window's UI by default and displayed when the settings UI appears), an app icon, the title text, a variable-sized Separator, and the three window control buttons (Minimize, Maximize/Restore, and Close).

I struggled to create the tabs-based update to this for a lot of reasons, the biggest being limitations in WPF. But I described where I finally landed in the previous article, .NETpad 2025: Finalizing the Tabs Layout (Premium), and I'm sure I'll update the design as needed as I work through all the code changes hinted at below.

The big thing here is that there's a TabControl in there called MyTabs, but there are no TabItems (tabs) defined in XAML. Instead, that all happens in C# code, dynamically.

And ... so far, so good.
Adapt the code to accommodate multiple documents (and tabs)
Previous to the release of .NETpad 3.0 for Windows 11 in late 2024, I used a series of what I think of as global variables to track document state information. For...

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

Thurrott