« MBS @ FMTraining.TV -… | Home | Extending Xojo with t… »

Modern Windows UI for Xojo

For years people asked about getting the Windows controls updated in Xojo. We still use Win32 API with various improvements over the years. But basically the same controls as they shipped with Windows 95 over 25 years ago. The style got updated, dark mode added as well as higher resolution support. In the past years Microsoft developed various ways to make controls and with announcements and deprecations, it was unclear for a long time which of the many ways would succeed.

For the future, there may be a Xojo version, that uses XAML based controls to implement all the standard controls: Labels, text fields, buttons, etc. You would open your project in the new version, build it and enjoy a fresh new look.

But what is XAML? It is a XML based declarative language to define controls and their attributes. You will not see the internal XAML code for the standard controls once they use it. But Xojo will generate it automatically from the properties set for the controls. On the way to this future, Xojo did some work to change Xojo in order to host XAML based controls on a normal window: See the video Getting to XAML Island by William Yu. You can read about them at microsoft.com here: Host WinRT XAML controls in desktop apps (XAML Islands).

Since the underlaying work with WinRT, the addition of manifest entries and the framework changes for Xojo are done, Xojo can now use XAML based controls. First a future version of Xojo will be able to host a new XAML container control. This is a kind of advanced control for Windows geeks. You need to provide the XML and it allows you to show all the available controls. A great way to add one or two controls to your application, that you need the most, like a modern list view or some picker. On macOS or Linux, the container would do nothing, so you may have two implementations for a cross platform application.

The pro argument for this is of course to get new shiny controls: Smooth scrolling, less flicker, animations built-in and a modern look to your application. But what are the cons?

First, this requires Windows 10, version 1903, or a later release (as shown on Microsoft website). So the question is, whether this will be the minimum version for Xojo to deploy. Which brings the question whether this will be enabled for everyone or be a checkbox on building or a property to set at runtime to opt-in. Maybe even opt-in per window, so we can update projects window by window.

Several APIs for the new controls are asynchronous, so the events in Xojo may come in a different order unless Xojo implements some extra code to make sure they fire in the same order as before. And it is not said, that the controls support the same events as for Win32. The new controls may not have the same properties to control, so Xojo has to adapt to them. And of course there will be new properties and methods specific to the new controls.

Next we wonder how existing custom controls in Xojo like the canvas will play into it and avoid flicker issues. The Listbox is a custom control from Xojo Inc. and draws a lot of content itself on all operation systems. We would certain prefer to port it over. The new standard controls may have different sizes, so you may need to adjust your layouts. You remember Web 2 controls being huge compared to Web 1?

For our plugin, all our extensions to existing controls will break. No idea whether or how we would go about adapting them. Same for declares to the Win32 API. Also our custom controls depend on Xojo still allowing them to embed in the Xojo window.

We look forward to the new controls, but we hope this is optional so we can keep building old projects without changes. And then later move to use newer control where it make sense.

You can watch the video from William Yu here:

28 04 23 - 10:31