Aspnetcore: XAML instead of HTML and CSS

Created on 27 Mar 2018  ·  28Comments  ·  Source: dotnet/aspnetcore

I am excited about this project, but I hope it does something about CSS as well. I think that XAML styles are more friendly, and they can be easily translated to CSS. Can It be done?
And if the DOM is represented as .NET classes, can we use XAML syntax to represent the page instead of HTML5?
I know that MVC brought back HTML instead of web controls to allow us to write optimum html code, but I think XAML is so close to html. I just want to use the familiar WPF /Silver Light/UWP controls with their familiar properties, methods and events, and they can be just a wrapper around html controls. This will shorten the learning cycle, and make the blazor looks like a regular WPF/UWP window, with c# code behind page.

area-blazor

Most helpful comment

A lot of C# developers love to use XAML over HTML and CSS. Many people wanted official cross-platform support for UWP/WPF/XAML. Imo Microsoft should support XAML too with Blazor. When will we even get official cross-platform support for XAML?

I myself am a fan of C#, but my issue with Web development and Electron was never Javascript. It is CSS.

What's the point of Blazor if it's not offering an alternative for HTML/CSS? Why is finding a replacement for HTML/CSS so difficult, why is cross-platform XAML so difficult... I just don't get it. Microsoft is always missing opportunities and making unwise decisions.

The day XAML becomes cross-platform (officially supported by Microsoft), that's the day Blazor gets full support of all C# developers. Well, at least not for me... because I see no real advantage of Blazor. Because I'm STILL dealing with CSS, id, class,

hell. Just with C# instead of Javascript

All 28 comments

For Blazor we are targeting C#, HTML, and CSS, but for XAML you can take a look at Ooui.

@danroth27

For Blazor we are targeting C#, HTML, and CSS, but for XAML

I don'y say you stop using HTML and CSS. I say give us the option to choose XAML if we want. I know that there is a web community, but there is also .NET desktop community that wants to write web apps. Please consider them. I myself hated ASP.NET despite my efforts to read about and learn it during the last 15 years! On contrary, I found XAML attractive, powerfull and easy to learn. I hoped that silver light will dominate and evolve to be Microsoft Wen technology, but it died in 2012!
I hope you conseder this suggestion, even if you name it Xlazor :)

XAML you can take a look at Ooui.

I don't depend on third party product at such large scale, because I don't grantee they will last and evolve, so it can be a miss if a third party product died so I need to rewrite large projects that use it!

@MohammadHamdyGhanem Blazor & Ooui are separate products founded on WebAssembly much as .NET is based on .NET Framework. Both of them are necessary as there are web developers which prefer Razor/HTML/CSS (ASP.NET) and Desktop/Mobile developers which prefer XAML. So I think both need to be merged into .NET/Xamarin (blazor already is merged) and should be separately used so they can be kept lightweight and do not mess each other.

@plamen-i
I agree. But I'm not familiar with Xamarin yet. I prefere to use UWP-like controls.

@MohammadHamdyGhanem Xamarin, especially Xamarin.Forms is the future is you want to write once (C#/XAML) & run everywhere. Invest some time to learn Xamarin.Forms and it will pay you back much more :-) It's mature technology, uses XAML and is very close to WPF/UWP.

I say Microsoft should make a XAML standard API (Like .NET Standard) that should be obeyed be Xamarin, UWP and ASP.NET whatever razor name, or extend .NET Standard to include this.
Controls and their properties and methods should have the same names whatever the underling implementation. This will make all these components easier to learn, and make the most of the code reusable.

@MohammadHamdyGhanem They are I think... Here's the repo for that but it's been quite dead for these past few months. I do hope it's not and await some announcement for it on Build 2018.

That is a relief. Thanks.

xamarin.forms are not as performant as native anroid or ios apps, it is good for statis content on the apps or cloud connected apps, but if u really want deep integration with OS apis and need native performance xamarin isnt as performant , plus the toolking of xamarin.native is just awful,

I went ahead and started building a Xaml engine that runs natively in the browser. You can check it out here: https://github.com/XamlEngine/Samples

XAML has to be an option. I don't know how much Asp.Net team is familiar with XAML. Team is spending time on recreating wheel. Like in recent Community Standup they have shown how to create Components in Blazor. I said why?. And why I have to learn new way of writing components. You have XAML which perfect for all this things.

There are thousand of JS framework like VUE, Angular, React which helps on data binding. And XAML was the first to do all this. At least give it a try.

We are familiar with XAML, but our primary goal with Blazor is to target Web developers, so we're sticking with HTML and CSS. That said, there are already various efforts out there to build XAML support for .NET on WebAssembly (Ooui, Uno, FrogUI) so we recommend looking at those projects if XAML is your preference.

@danroth27
I see that MS must work on XAML razor to save VB.NET. In my opinion, ASP.NET was one of the reasons that made VB.NET popularity go down over the past decade. VBScripts run only in Internet Explorer, So it is born dead and any web developer had only to use JavaScript which uses C-Like syntax, so it is easy to be used with C# than with VB.NET. Over the years JavaScript frameworks kept emerging, and MS adapted some of them like JQuery and Angular. TypeScript also is some advanced JavaScript.
This made C# is the only logical choice for beginners, even forced many VB.NET developers to migrate to C#.
So, Xaml blazoer has two goals:

  1. Attract c# desktop developers. Ocertime it will over kill html fans!
    2- Attract vb.net developers and save this beautiful easy for beginners language.

I think there is a misconception about XAML here. I am really a fan of XAML in Blazor but not the way discussed above and in aspnet/Blazor#374.

What i am suggestion is described below:

The problem

Imagine i have these components:

Drawer.cshtml:

<aside class="mdc-drawer mdc-drawer--modal">
    @Header
    @ChildContent
</aside>

@functions
{
    [Parameter]
    DrawerHeader Header { get; set; }

    [Parameter]
    RenderFragment ChildContent { get; set; }
}

DrawerHeader.cshtml:

<div class="mdc-drawer__header">
    @ChildContent
</div>

@functions
{
    [Parameter]
    RenderFragment ChildContent { get; set; }
}

Now imagine in my 3rd component Main.cshtml i want to add a Drawer and set its Drawer.Header. Currently i have to create a property of type DrawerHeader and bind it to my Drawer.Header:

<div class="drawer-frame-root">
    <Drawer Header="@Header">
        <DrawerContent>

        </DrawerContent>
    </Drawer>
    <DrawerScrim />
</div>

@functions
{
    DrawerHeader Header
    {
        get;
    } = new SubClassOfDrawerHeader();
}

Therefore i have to create another component named SubClassOfDrawerHeader and assign the Header property to it. Which makes a tons of components in my project.

My Proposal

My suggestion is to use XAML style property nesting:

<div class="drawer-frame-root">
    <Drawer>
        <Drawer.Header>
                <DrawerHeader>
                        <DrawerHeaderTitle>User's name</DrawerHeaderTitle>
                        <DrawerHeaderSubtitle>[email protected]</DrawerHeaderSubtitle>
                </DrawerHeader>
        </Drawer.Header>
        <DrawerContent>Some content</DrawerContent>
    </Drawer>
    <DrawerScrim />
</div>

Please look at <Drawer.Header>...</Drawer.Header> in above code.

@MohammadHamdyGhanem @xclud Have you taken a look at a similar platform based on Xaml as you wish - Platform.uno - as mentioned by @danroth27 earlier?

If it has XAML I think we would INSTANT move to blazor, because we really enjoyed Silverlight.
HTML/Javascript coding == very annoying way to write code (aka "script")

If it has XAML I think we would INSTANT move to blazor, because we really enjoyed Silverlight.
HTML/Javascript coding == very annoying way to write code (aka "script")

@wstaelens I enjoyed Silverlight very much too, and made a dozen apps with it. This is why I am enjoying Uno Platform (a.k.a. Silverlight on steroids) right now.

If it has XAML I think we would INSTANT move to blazor, because we really enjoyed Silverlight.
HTML/Javascript coding == very annoying way to write code (aka "script")

@wstaelens I enjoyed Silverlight very much too, and made a dozen apps with it. This is why I am enjoying Uno Platform (a.k.a. Silverlight on steroids) right now.

The problem is that this is not an "official" microsoft project, so life time... support... whatever… blazor just needs XAML support.

The problem is that this is not an "official" microsoft project, so life time... support... whatever… blazor just needs XAML support.

@wstaelens Understood absolutely. I view Uno as something standing on the shoulders of Microsoft giants - UWP, mono, Xamarin... They did not build the platform from scratch, but brilliantly utilize many mature technologies have been working very well. I was really glad to see Uno well received at Microsoft Build last month and the recent endorsement by Miguel de Icaza.

A lot of C# developers love to use XAML over HTML and CSS. Many people wanted official cross-platform support for UWP/WPF/XAML. Imo Microsoft should support XAML too with Blazor. When will we even get official cross-platform support for XAML?

I myself am a fan of C#, but my issue with Web development and Electron was never Javascript. It is CSS.

What's the point of Blazor if it's not offering an alternative for HTML/CSS? Why is finding a replacement for HTML/CSS so difficult, why is cross-platform XAML so difficult... I just don't get it. Microsoft is always missing opportunities and making unwise decisions.

The day XAML becomes cross-platform (officially supported by Microsoft), that's the day Blazor gets full support of all C# developers. Well, at least not for me... because I see no real advantage of Blazor. Because I'm STILL dealing with CSS, id, class,

hell. Just with C# instead of Javascript

I disagree, all web developers are used to html and css. Please stick to html and css

@GoranHalvarsson then why they are not used to JavaScript or TypeScript?

I disagree, all web developers are used to html and css. Please stick to html and css

Unfortunately not all web authors are developers, some are software engineers and we prefer XAML/C# to center elements vertically on a page. Which is still a mystery in HTML/CSS. XAML is far superior.

I have a Skoda and a Porsche, but only drive the Skoda because I'm used to it? There is Xamarin as an option or Avalonia (If Microsoft owned it and it replicated the WPF spec). Maybe Microsoft should put a survey out to Blazor community and ask them if they had to pick one would it be - XAML or HTML?

Silverlight developers over 10 years ago considered themselves web developers. Just because iOS and Android decided to not allow plugins, a lot of web developers were left without a platform to develop for.

@GoranHalvarsson When you say all web developers, a lot of us are used to html and css (because we have to be), but prefer XAML/C#. You don't speak on behalf of the web developer community. So don't tell us what we should stick to.

And what's wrong with having multiple technologies available to developers?

I have used HTML, CSS, JavaScript extensively (I try to stay away from JavaScript as far I can nowadays) for web projects.
When it comes to Rich Internet Applications (RIA) or Single Page Apps (SPA), Xaml and C# are the king and queen. I will not take any other option.
I have to admit that I am among the fortunate who are not subject to any imposed platforms, the luxury not everyone has.

I recently completed a Blazor Project SSB (I far not use CSB yet) using Telerik and SyncFusion. The C# experience was great! The JavaScript / html / CSS was irritating. It seems most of the third party controls have most bugs within CSS. You wouldn't want to build a large scale SPA this way ATM, it would be a pain to maintain.

In the past I have extensive XAML / C# experience. I must say having everything under one roof makes development not only faster and more reliable, but also more enjoyable.

Personally, I don't care all that much if XAML / C# support is not in the browser as long as it's cross plat. It's probably as important to have continuity in a tech stack, with simple ways to migrate to newer tech. One of the largest past issues (putting Silverlight aside) was with using third party ORM solutions, always stick with Microsoft supported tech whereever possible is my advice!

If Microsoft added cross platform / WASM support to WPF and WinForms the problem would be solved for me. I'd probably never use Blazor again if this was the case, as we'd all have the ultimate solution as an option.

Was this page helpful?
0 / 5 - 0 ratings