In antecedent accessories we’ve covered how the Uno Platform takes a beheld timberline authentic in the XAML markup accent and creates it on iOS, Android, and WebAssembly. In this commodity I appetite to dive into a key average step: how the XAML is parsed and mapped to generated C# code. In allotment 2, we’ll attending at a few added means in which Uno leverages cipher bearing to accomplish the auto turn.
XAML stands for eXtensible Appliance Markup Language. It’s an XML-based syntax. Although it can be acclimated to call appealing abundant anything, it’s geared against anecdotic the anatomy of an application. It was aboriginal acclimated in Windows Presentation Foundation, and back again has been acclimated (with accessory syntactic differences) in a cardinal of contexts, including Silverlight (RIP), WinRT, Xamarin Forms, and the Universal Windows Platform.
XAML hits a candied spot: it’s animal readable, expressive, and abundantly structured to abutment architecture accoutrement like Blend and XAML Designer. One nice affection is that it can be seamlessly intermingled with C# via code-behind files.
To tap into that power, Uno needs to be able to apprehend a XAML book and catechumen it into compileable C# code.
The aboriginal footfall is to anatomize the book into a Xaml article tree, application the System.Xaml namespace.
Next, the Xaml article timberline is candy into a C# chic definition. The aggregate of the abundant appropriation is done in the behemothic XamlFileGenerator class. We angular on the Microsoft.CodeAnalysis API actuality (aka ‘Roslyn’) to bout types acclimated in XAML to types authentic in the app accumulation or its dependencies. The achievement is adored to a generated file.
All this happens abaft the scenes whenever you body an Uno head.
Let’s attending at a accurate example. This is allotment of the markup we put in MainPage.xaml in a antecedent article:
The generated achievement can be begin in the ‘obj’ binder beneath the activity head.
The cipher book generated from MainPage.xaml.
This is a allotment of the generated code, assuming the achievement for the XAML atom above:
What a mouthful! Generated cipher tends to be optimized for apparatus readability, rather than for animal readability. For example, the absolute casts to XamlApplyHandler were added back we begin that the compiler was accepting to do a lot of computationally-expensive blazon inference. That one change angled the accumulation acceleration for ample XAML files.
In the accustomed advance of Uno development you don’t charge to attending at cipher generated from XAML or alike apperceive that it’s there, admitting occasionally it’s advantageous to booty a blink back debugging.
Recall that the Button_Click accident is authentic in the code-behind for MainPage. As far as the compiler is concerned, both the authored and generated files are aloof fractional definitions of the aforementioned class.
One aftermost fun fact: back architecture on MacOS application Beheld Studio for Mac (which Uno tentatively supports in preview), Uno uses an centralized anchorage in abode of the System.Xaml namespace which isn’t accessible on Mac. The aforementioned cipher backs Uno’s abutment for runtime Xaml estimation via Windows.UI.Xaml.Markup.XamlReader, which is acclimated in the alternate approach of the Uno Gallery app and Uno.Playground website.
Eliminate Your Fears And Doubts About Xamarin Forms Xaml Designer | Xamarin Forms Xaml Designer – xamarin forms xaml designer
| Delightful in order to my own blog, in this period I’m going to demonstrate in relation to xamarin forms xaml designer