On May 7, 2018, Microsoft announced the release of Xamarin Forms 3.0. This is their fastest and richest release till date combined with fantastic improvements up and down in the Xamarin stack like the latest XAML IntelliSense experience released with Visual Studio 2017.
When you are going to upgrade your Xamarin forms to Xamarin forms 3.0. You will see the styling power and new layout which will improve on how you are going to create your UI including Flex Layout, Style Sheets, Visual State Manager, and right-to-left support just to name a few. In addition to micro-optimizations, XAML compilation has got the special attention to show the build time is reduced by 88% in some of the benchmarks.
In this post, we will talk about some of the new features in Xamarin Forms 3.0 for mobile app developers.
If you ask mobile app developers about what type of improvements they are looking for in the framework of their choice. Performance is one of the top priorities for many developers. Xamarin.Forms are no exception to this and Microsoft is working and spending a lot of time on improving a variety of performance enhancement.
One of the main initiatives taken by Xamarin in this aspect is called as “Fast Renderers”. In Xamarin.Forms controls pass through components called renderers when they are required to be translated into native view of the target platform. As the name suggests, fast renderers are the effort to improve the performance of the rendering pipeline on different platforms.
There is a lot of improvements in Xamarin.Forms 3.0 when it comes to performance and many of them will come for free without any need to make any changes in your application.
Visual State Manager
Visual state manager is a well known and loved feature in other Xamarin platforms and Xamarin has bought this new feature in Xamarin.Forms 3.0. You can create and define various states for your layout and control directly in Xamarin or C# and easily update the UI of your app. Here is the visual view which handles both portrait and landscape orientations:
In order to change the position of the capture button, last image button and close button appear depending on the change of orientation. It is advised to use Visual State Manager. For that, first define your states in page resources:
There are two groups, one for each control which needs to be updated, for simple understanding they share the same state names. In order to change the state in the page’s C# file, call them using the following command:
Note: Some calculation might be required for the determining the orientation and target that particular state.
FlexLayout is the new layout which is inspired from web’s Flexbox. Just like web browsers can be of any size, the various screen dimensions that your Xamarin.Forms application can run has grown significantly. FlexLayout promotes performant, flat and flexible UIs. Moreover, FlexLayout is ideal for handling distribution and spacing the content in your layout. It also provides the control for the direction of your layout, justification and alignment among other properties.
Start using FlexLayout for researching on brand new resources.
CSS(Cascading Style Sheets) is a companion to FlexLayout given their heritage. Using CSS for designing your layouts is an optimal manner to express design in tandem with Xamarin. We know that many of the mobile app developers love CSS with experience in mobile web development technologies and we also recognize that Xamarin developers love to express their styles in Xamarin. Both these productivity options can be used with Xamarin.Forms 3.0.
StyleSheets can be added as a separate CSS file in your other project or inlining your resources. To compose your style there is a wide range of common selectors available with Xamarin.Forms 3.0.
While it was possible before in Xamarin.Forms to support right-to-left, but it was not as easy as it should have been. From that point, we have created the necessary API to easily use and read the regional settings of the user, as well as it updates the layouts and controls to accompany those settings. It is very simple as doing the following in Xamarin for layout and controls:
Previews of New Platforms
The new version of Xamarin.Forms come with updated and new previews for new platforms, which includes MacOS, Tizen, WPF, and GTK#. Each of these platforms is in the varying stage of maturity, so do look for the support on the Xamarin website. Moreover, by bringing Tizen into the mix you can extend your Forms application to millions of Samsung devices supporting Tizen.
These are some of the highlights of what are the new features in Xamarin.Forms 3.0 for mobile app developers. However, it is safe to say that the framework is quickly evolving and becoming an ideal choice for mobile app development. Between the improvement in performance, extending target to reach number of platforms and ability to mix Xamarin.Forms with native mobile apps wherever it makes sense. It is a good time to be a Xamarin developer.