Unnecessary binding
One of the best parts of XAML is, without a doubt, data binding. However, you do have to be careful and use the right pattern for the job.
For instance, don’t bind a Label’s Text property to a view model property that will never change. Of course, that’s a great approach if the text is going to change dynamically, but if it isn’t, don’t waste the CPU cycles.
Grid layouts
When you are using a Grid, make sure that as few row and columns as possible are set to “Auto” sizing.
If you can use fixed heights and widths, favor those.
If your design requires a more flexible layout, use the proportional layout options, also known as “star” values. For example, the following XAML will define 2 rows, the first row will take up 1 third of the grid, the second row will take up 2 thirds.
<RowDefinition Height="1*" /> <RowDefinition Height="2*" />
Relative layout
Relative layouts position views relative to properties of the layout or their siblings.
This type of view requires significant layout overhead and should be avoided wherever possible.
Vertical and Horizontal Options
The default values of Fill and FillAndExpand allow for the best layout optimisation, so if you can avoid setting these properties, do so.
VerticalTextAlignment
This is an expensive property to use. Avoid setting wherever possible.
Reduce the number of elements on the screen
Also known as the Visual Tree Size, it’s no surprise that the number of elements on the screen directly impacts the rendering speed.
If an element is obscured by other elements, use IsVisible to hide it or remove it altogether.
Wrap-up
Each new release of Xamarin Forms includes more and more efficient renderers and many performance improvements. These improvements, together with the tips above, will help you achieve fast rendering and smooth UI’s.