7 Ways to Boost Your Xamarin Development Productivity | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (215)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (915)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (628)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (592)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)

7 Ways to Boost Your Xamarin Development Productivity

There are many ways to improve your productivity when developing a Xamarin.Forms application. Here, I have summarized a few things from my own experiences. The following are the phases of typical Xamarin.Forms application development:

  1. Design
  2. Develop business logic
  3. Build
  4. Test
  5. Deploy

The following are the most common tools and techniques that improve the life-cycle phases of developing an application in Xamarin.Forms that I will discuss in this blog:

XAML

The appearance and performance of your application depends on how you organize and present UI controls in Xamarin.Forms. It is necessary to nest different layouts and controls to create your desired UI. Creating and editing different layouts and various controls in the code-behind will make it difficult to read and clumsy to work with. So, the better solution is to use XAML in all possible cases.

XAML code: easier to read and maintain

XAML code is easier to use and read when compared with its equivalent counterpart, C# code. Compare the following simple example XAML and C# code.

XAMLC# Code-Behind
<StackLayout>
<Label Text="{Binding Name}"/>
</StackLayout>
StackLayout stackLayout = new StackLayout();
Label nameLabel = new Label(); 
nameLabel.SetBinding(Label.TextProperty, "Name"); 
stackLayout.Children.Add(nameLabel);

XAMLC

A few months back, before recent Visual Studio and Xamarin updates, XAML files were embedded along with executables when deployed. Now, XAML files are compiled along with the C# files, known as XAMLC compilation. This feature is enabled by default when creating a Xamarin.Forms application (at the time of writing, I am using Visual Studio 2019 version 16.3.6). If you are not using the updated versions, still you can enable XAMLC by following the steps in this documentation.

How does enabling XAMLC boost your productivity?

  • It performs compile-time checking of XAML, notifying the user of any errors.
  • It helps reduce the file size of the final assembly by no longer including .xaml files.

Design-time data

Design-time data can be used to visualize a UI with mock data. It is very useful when you do not have the ViewModel before you start building the UI. Design-time data populates mock data in the XAML Previewer to visualize the XAML layout. Refer to this blog for more details.

Patterns

There are many patterns you can choose for your application. This Microsoft documentation outlines a few standard patterns. The most commonly used one is the Model-View-ViewModel (MVVM) pattern. This pattern helps to clearly separate the business and user interface logic of an application. Following the MVVM pattern will greatly help you maintain, test, and evolve your application by eliminating duplicate code and increasing the possibility of reusing code. It allows developers working on business logic and designers working on UX designs to work independently and simultaneously, improving the project’s productivity.

Open-source libraries and frameworks

It’s often accurate to apply the statement, “All the easy problems have already been solved,” to software development. Therefore, you just have to pick the right solution. Coming to Xamarin.Forms, there are many open-source libraries waiting to be used. You can skip most portions of the design phase of your application by using the following open-source projects:

  • FFImageLoading: Library for loading images quickly and easily on Xamarin.iOS, Xamarin.Android, Xamarin.Forms, Xamarin.Mac/Xamarin.Tizen, and Windows.
  • Essential UI Kit for Xamarin.Forms: Elegantly designed XAML templates for Xamarin.Forms applications. These templates are compatible with Android, iOS, and UWP platforms, and use the MVVM design pattern to provide trouble-free integration. You can get the complete design implementation for free from GitHub.

Though you can develop applications based on the MVVM pattern using the features available in the Xamarin.Forms framework, there are still certain items you have to do on your own, such as navigation services. Instead of writing your own implementation, there are many MVVM frameworks available you can use to save time. Some of the widely used frameworks are:

Custom controls

When you create a Xamarin application, most of the time, it is not possible to achieve your expected UI with the framework controls. So, you end up creating multiple custom controls and platform-specific renderers. Creating your own controls is a desirable choice, only if it doesn’t require too much work to create and maintain them.

Using third-party custom controls is a solution that reduces design and maintenance costs of your application. For this, Syncfusion—a market leader in Xamarin.Forms components—has 145+ Xamarin UI controls that can be used in your application for all scenarios, and provides simple and straightforward licensing.

Rapid iteration using Hot Reload

Until a few months ago, you had to build and deploy again and again to verify even the simplest changes in Xamarin.Forms applications. This was quite a time-consuming process, recompiling and redeploying the entire application for every little change. Hot Reload is a great feature recently introduced by the Xamarin team that addresses this. With the Hot Reload option enabled in Visual Studio, the changes you make in the XAML file are reflected live in your running app with the current application state. The following table lists the Visual Studio and Xamarin.Forms versions that support Hot Reload. Please refer to this blog for more details about the Hot Reload option.

IDE/FrameworkVersion Required
Visual Studio 201916.3 or greater
Visual Studio 2019 for Mac8.3 or greater
Xamarin.Forms4.1 or greater

Note: At .NET Conf 2019, the team announced Xamarin Hot Restart. The Hot Restart option will allow you to rapidly verify the changes you made in the code-behind and resource files. This is achieved by pushing the new assemblies directly into the existing app bundle, instead of redoing a complete build. This is going to be the most welcomed feature by Xamarin.Forms developers. Refer to this blog for more details about it, along with statistics showing its performance impact.

Build-time optimization

Building an application certainly takes a considerable amount of developers’ time, especially when it comes to building Xamarin.Forms for Android projects. There are a few properties that you can use to speed up the build process in Xamarin.Forms application. Refer to this blog for more details about the combination of settings that can be used to optimize build times.

Continuous integration

Though you can use Hot Reload and build optimization options, at the end of the day, someone must make the build that will be delivered to testers and end-users. We often come across a situation where the build works as expected on our end, but misbehaves on the customer’s end. Continuous integration (CI) is the best solution for these kinds of struggles. Not only for Xamarin.Forms, but for any domain or platform you work with, CI will improve your productivity without a doubt. To help you implement CI in your Xamarin.Forms projects, Visual Studio offers the App Center.

App Center can build the application for every commit you make in your repository, test the application with many virtual devices, and distribute the application to the various collaborators to use or test further. The most useful part of the App Center is it can report many analytical and diagnostic data points, like crash reports, user history over various modules of the application, and more. There are free and paid versions of App Center available. Refer to this documentation for more details.

Conclusion

The tips I listed in this blog are all from my own experiences, and I hope they will help you too. My colleagues and I invite you to see all our Xamarin.Forms controls in action by downloading a free trial. You can also explore our AndroidiOS and UWP demo apps. You can learn about the controls’ advanced features in our documentation.

If you have any questions about these controls, please let us know in the comments below. You can also contact us through our support forumDirect-Trac, or feedback portal. We are happy to assist you!

Tags:

Share this post:

Comments (3)

Are you able to provide an example of design time data with the SfDataGrid as I’m unable to get it working, I can use design time data with a listview easily but not with your controls.

Balasubramani Sundaram
Balasubramani Sundaram

Hi Richard,

Your requirement to design-time sample for SfDataGrid is attached in the below Link, please refer the below sample for more details.

Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGridDemo-1685267748

Regards,
Balasubramani Sundaram

Well documented, gives good direction on where to start. thank you.

Comments are closed.

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed