Microsoft-ui-xaml: Proposal: Support Razor/Blazor-like Syntax

Created on 20 May 2020  路  7Comments  路  Source: microsoft/microsoft-ui-xaml

Proposal: Evolve XAML Syntax to also support a more Razor/Blazor-like syntax

Summary

I saw @jeromelaban today show an experiment with using Blazor-like syntax for XAML, and I think this would be a good evolution of XAML:

image

Rationale

I've for a long time thought that XAML needed to evolve more beyond it's initial incarnation from WPF, and make xaml more succinct and efficient to write. We've seen this happen with ASP.NET which is almost not recognizable today compared to where it started, with much much less markup and code needed to create great UIs.

I think this flavor has several benefits:

  • First it's still very much XAML-like reusing the same tags, and simplifying bindings.

  • It removes the need for code-behind for UI specific code, and drives you towards better separation between UI code-behind and VM/Model code. The current model drives people to add too much in code-behind, beyond just view-specific code.

  • The syntax will be very familiar to those already using ASP.NET MVC / Blazor.

  • Way more succinct

This article is a pretty good take on why it's time for XAML to evolve (note it has now been 14 years): https://paulstovell.com/six-years-of-wpf/

feature proposal team-Markup

Most helpful comment

I'm usually a bit apprehensive about new XAML syntax/dialects. This is largely because every time there is a new 'latest-and-greatest' tech we seem to loose capabilities that were in the original WPF XAML (it took a long time for UWP to get where it is today, Silverlight is a sadder story, Xamarin Forms... I don't want to talk about that).

This proposal is a best of both worlds though. It's modern and simplifies code yet retains the full capabilities we have in XAML today while opening the door for new ones. I wouldn't mind porting existing XAML to this syntax at all.

All 7 comments

It was really cool to see that on the call today. @jeromelaban and the nventive team are invaluable to the future of XAML and cross-platform. I'm continuously astounded by what they are cooking up.

I think this would be the way to go in the future, i love xaml from the day i tried it and after xaml a lot of things like xml/html gave me a more quirky feeling but after blazor i do find myself troubled looking at xaml ^^

Please, do it!!

I'm usually a bit apprehensive about new XAML syntax/dialects. This is largely because every time there is a new 'latest-and-greatest' tech we seem to loose capabilities that were in the original WPF XAML (it took a long time for UWP to get where it is today, Silverlight is a sadder story, Xamarin Forms... I don't want to talk about that).

This proposal is a best of both worlds though. It's modern and simplifies code yet retains the full capabilities we have in XAML today while opening the door for new ones. I wouldn't mind porting existing XAML to this syntax at all.

Thanks for opening this proposal @dotMorten, as a former ASP.NET MVP. I do love Razor syntax :)

This syntax will really welcome new devs to try out Windows development using XAML. It is short and sweet.


  1. > It removes the need for code-behind for UI specific code, and drives you towards better separation between UI code-behind and VM/Model code. The current model drives people to add too much in code-behind, beyond just view-specific code.

@dotMorten You mention an important aspect, but your example doesn't show the part with "too much code-behind".
In my experience the code behind is necessary only to cover specific lack of MVVM support in the controls. So the actual problem is else where. Even with in the current state, a good way to handle this is by some reusable behaviors so you don't actually have to write that code-behind in every screen.

  1. The XAML definitely must keep evolving and at a faster pace. In the same time, there are important decisions to be made regarding how exactly it evolves. Too much "evolving" could make it something else. If the decision will be that a radical evolving must take place, maybe the option to converge to the ASP.NET MVC/Blazor-like style is better in my opinion.

Obviously such decisions are not a walk in the park. I'm sure the actual XAML architects at Microsoft have a very comprehensive view of the shortcomings of XAML which surfaced in 15 years since XAML was launched. I'd love to hear their thoughts, maybe here maybe somwhere else...

Was this page helpful?
0 / 5 - 0 ratings