Programming Windows: Hello, WinFX, Avalon, and XAML (Premium)

For developers, it was a unique pleasure seeing Don Box and Chris Anderson write Longhorn/WinFX code live during Jim Allchin’s PDC 2003 keynote. But what was this strange new software code? And is it possible that this now-ancient technology still works today?

Why yes. Yes, it is possible. And yes, it does still work.

With a few modifications, of course: in the years since this event, WinFX evolved into the .NET Framework 3.0, and Avalon became Windows Presentation Foundation (WPF). And during that shift some .NET namespaces and other features changed, as did some capabilities. But the code that Box and Anderson thrilled us with in October 2003 is, fundamentally, still viable today. And that says a lot, I think, about the quality of the developer environment that Microsoft created 20 years ago.

On that note, we should take a moment to reflect on this incredible achievement today, especially given how terrible and disjointed things became for Windows developers in the intervening years. As it turns out, WinFX, like Longhorn, represented an apex of sorts, in this case for Windows app development. And it’s been a steady downhill ride ever since then.

Are you back? Cool. Let’s look at that code.

The initial version of the app that Box and Anderson created is sheer simplicity. It had a single C# file that contains a single namespace, and that namespace contained the app’s Main() method, which is its entry point. They included three WinFX libraries to get their contained functionality, and inside of Main(), they instantiated a new window after populating its Text (the title bar caption) and Visible properties.

To compile this, they needed to add references to three DLLs--- PresentationCore, PresentationFramework, and WindowsBase---and specify that the target app was a Windows application (as opposed to a console app). After a quick churn of the C# compiler, voila, a blank window that required just a few lines of code.

Recreating this simple app today in C#, the .NET Framework, and Windows Presentation Foundation (WPF) requires only small changes to the code. In fact, the biggest problem is getting around Visual Studio’s innumerable niceties, which include prebuilt project types for WPF (and other app types) with canned code spread out over multiple files. (Getting to a blank window in Visual Studio literally requires zero lines of code, since all the boilerplate is provided for you.)

I experimented doing this using different methods. Via the command-line and with a plain text editor, which is tedious. (You can even create a blank WPF app now from the command line using dotnet new wpf -o [project name], which is fun.) Via Visual Studio Code, which works but is surprisingly slow. And via Visual Studio, of course. That latter choice has many different starting points, but what I finally settled on was the following:

Use Visual Studio 2022 to create a C#/.NET Framework console app. This provides the lea...

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