WinUIpad: Fonts, Dynamic Document Title Display, More
Last week, I discussed my new rewrite of .NETpad as WinUIpad, using the Windows App SDK and WinUI 3. Since then, I’ve made two major additions to the code, which you can now find in the WinUIpad 2026 repository on GitHub: Font configuration now works properly, and I somehow managed to solve a months-long issue with a custom converter, so now the document filename displays properly too.
Fonts
The original version of the app I posted didn’t include working font code, so the font name (family), size, italicization, and weight (bold) features were stuck at the default values (Consolas, 18 point, no italics or bold).
Explaining how I fixed this is a bit difficult, but there’s enough font-related code that needs to run when the app starts that I create a Font_Configuration() method to segregate that from the rest of the code in LoadAppSettings(). Most of that was working fine already, but the correct font name (family) wasn’t displaying at all, so I fixed that.
And then I finally just created Selection_Changed event handlers for the Font family, Font style, and Font size combo-boxes in the settings interface and added code so that any changes the user made to each would impact the font used by the main app’s Textbox and then save the change to app settings. So that all seems to work properly now and font changes of whatever kind persist between app runs.
Dynamic document name display
This one I’m really excited about, as it had been a months-long source of frustration. As I wrote in .NETpad 2025: Running Up That Hill (Premium) back in August, I have been struggling to use data binding wherever possible in this project and finally discovered that one of the issues I’ve experienced is tied to an (at least) four-year-old bug in the Windows App SDK/WinUI 3 that Microsoft knows about and has never fixed.
Without getting into the weeds on this one, there are two ways you can implement data-binding in XAML with the Windows App SDK/WinUI 3: The x:Bind markup extension, which is the newer and more efficient way, and the Binding markup extension, which is the old-fashioned and less efficient way. Obviously, I assumed I’d be using x:Bind everywhere possible, and it usually does work fine. Except in this one case.
This app has a custom title bar, and the TextBlock control I’m using to display the document title at the top of the app window can be data-bound to the FileName property in my Document class so that it displays dynamically as the user opens new documents, saves an existing document, or creates a new, empty document. The problem is that it will display the entire file name, including its path and file extension by default. Like so:
To fix this, I create a custom converter that strips away the path and file extension. This is found in FileNameConverter.cs (in a new Converters folder, as I will be using a few other custom converters soon, too). There’s a lot that goes into this, but basically you just a...
The post WinUIpad: Fonts, Dynamic Document Title Display, More appeared first on Thurrott.com.