My #MAUI Day talk - part 3

My #MAUI Day talk - part 3

This is part 3 in a series recapping my talk from MAUI Day (in London). This will make much more sense if you read part 1 and part 2 first.


The tools we get "out of the box" for working with XAML in MAUI basically come down to creating a sparsely populated application and the need to type everything by hand (with a bit of intellisense).

I've created some tools (and experiments) that make getting from nothing to a basic project architecture much easier, and from an empty file to useful appropriate XAML content much faster.


The MAUI App Accelerator is a Visual Studio extension that enables the creation of MAUI apps through a wizard-style interface. (Remember I said I like GUIs.)

It allows you to specify :

  1. Which version of .NET to use (You should be using .NET 9 for your MAUI apps!)
  2. Whether you want to use XAML+MVVM, XAML+CodeBehind, or C# to create your UI
  3. If you want to use the Shell, and what sort of navigation style (tabs or flyouts) to use
  4. How many pages you want in the app, what they should be called, and what (if any) default content they should include
  5. What features, functionality, libraries, and dependencies should also be included in the app

It then produces an application with all these options, all correctly configured and with dependencies and initialization already done.

It doesn't sound like the most revolutionary thing in the world, but it can definitely save minutes and maybe even hours to go from nothing to a complex working application full of correctly configured and useful dependencies.


That's great for new apps, but what about extending existing apps?

Well, version 2.0 is "coming very soon", and among numerous other improvements is the ability to use the same wizard to add new pages and features. Of course, it does this with the same level of integration into the existing app, so it automatically registers dependencies, adds resources, and correctly configures and initializes all it adds.

Screenshot showing the new "Add page..." and "Add feature..." options
These new options can be a massive time saver


So, that's great, we can now build the basic structure of our application much faster, but what about getting the XAML we want inside the pages of the app?

I have two ideas to show on that subject.


First is the Pro XAML Toolbox.

This is a variation on the default Toolbox, but it adds more useful and appropriate content to the page. Many options are configurable, and items can be dragged where desired or double-clicked to be added where the cursor is.

The Pro XAML Toolbox in action. Showing different elements being very quickly added by dragging and double-clicking on elements  in the toolbox
See how quickly a page can be filled with useful, appropriate XAML

While that allows the creation of XAML much faster than typing by hand, I still think there is a faster way.


For most data types in a ViewModel, it's possible to make a reasonable assumption about the UI controls that can be used to display and allow interaction with them.

When those assumptions are codified (in a configurable way--of course), then it's possible to generate the XAML corresponding to a particular ViewModel file.

My preferred way of implementing this is to simply drag the ViewModel file onto the View and have the XAML code be automagically added.

When doing this, the file is analysed, and appropriate elements are created depending on the types, their names and if they can be changed.

See below that:

  • A bool called IsRefreshing becomes bound to an ActivityIndicator.
  • An ObservableCollection<T> produces a CollectionView and the DataTemplate includes entries for each of the properties for the Type.
  • Commands cause buttons to be added to the XAML to trigger the invocation of the command.
  • etc...

Animated screen capture of a file being dragged onto a file and appropriate XAML being created
No steps were removed. It really is this fast

It's also possible to open the ViewModel, select some properties and choose "Copy as XAML" which you can paste wherever you want.


As with the Pro XAML Toolbox, this isn't going to always give you exactly what you need, but it is much quicker and easier to make small modifications to something that is almost right than it is to type the entire thing from scratch.


This isn't all just me showing off. I'd much rather that someone else had created the above (and shown how XAML can be made more maintainable.)

The above is to show that other things are possible.

Given that this is possible, why has no one else done anything like this before? (There are a few command-line-based template options available, but nothing else with a GUI or as much flexibility. And nothing beyond that.)



Ok, we've seen that while everyone agrees that most XAML is bad, it doesn't have to be that way. I've also shown that there are ways of writing XAML to make it much easier and more pleasurable to work with, and that it's possible to create tools to make working with XAML files easier.

Is this as far as we can go?

Is this as good as it can get?


Microsoft doesn't seem interested or motivated to consider any big changes.

No one else is doing anything in this area.

That's not going to stop me.

Thanos:  "Fine. I'll do it myself."
Not that I want to be comparable to Thanos in other ways


In part 4, I share an idea I've had about a possible future evolution in working with XAML.

要查看或添加评论,请登录

Matt Lacey的更多文章

  • Why do you let your developers use XAML?

    Why do you let your developers use XAML?

    Serious question. If you employ or manage developers who use XAML to develop apps (with MAUI, WPF, WinUI, UWP, or…

    13 条评论
  • My #MAUI Day talk - part 5

    My #MAUI Day talk - part 5

    This is the final part in a series recapping my talk from MAUI Day (in London). This will probably only make sense if…

  • My #MAUI Day talk - part 4

    My #MAUI Day talk - part 4

    This is part 4 in a series recapping my talk from MAUI Day (in London). This will make much more sense if you read…

  • My MAUI Day talk - part 2

    My MAUI Day talk - part 2

    Part one is here. (You should probably read that first.

  • My #MAUI Day talk - part 1

    My #MAUI Day talk - part 1

    This is a summary of part 1 of the talk I gave at #MAUIDay last week. XAML is the default option for defining UIs in…

    6 条评论
  • Improving accessibility in MAUI

    Improving accessibility in MAUI

    .NET #MAUI has an ever-improving set of tools to help build apps that are accessible to as many people as possible.

    5 条评论
  • Evaluating the use of Copilot to create unit tests for code

    Evaluating the use of Copilot to create unit tests for code

    There's an idea that is being repeated a lot that writing unit tests for code is now much easier as you can "just" have…

  • Why you need to make intuitive, six-dimensional apps

    Why you need to make intuitive, six-dimensional apps

    The following is an extract from the first chapter of ‘Intuitive UX: The Six Dimensions of Mobile User Experience’. The…

社区洞察