Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Xamarin Forms Csharp or XAML

Felipe Momm edited this page Sep 26, 2016 · 2 revisions

When Microsoft developed the Windows Presentation Foundation (WPF), together with Model View ViewModel they also developed an XML dialect called XAML that can be used to code the views.

If you think about the Visual Content of a View it has a hierarchy of visual elements. At the top of this hierarchy you have the page. The page might then have a Grid or a StackPanel and the cells of these elements may contain more Visual elements including Grids etc. Ultimately at the leaves of this tree we have elements like labels and text entry boxes.

This entire structure of objects can be described in XML with XML element types corresponding to class objects and XML attributes corresponding to class object properties. Compared to CSharp, coding a view in XAML results in a reduction in key strokes and the elimination of noise makes XAML easier to read and understand improving developer productivity.

Despite this, it would seem that more than 50% of Xamarin Developers prefer to use C#. One possible reason is that in C# they could use intellisense to aid the coding. But it is now possible to use intellisense in XAML and further more with Blend one can visually design forms.

However given the popularity of C#, our first example is based on c# views. Our second example produces exactly the same result but is based on XAML so you can compare the two and understand how to move from C# to XAML.