XAMARIN
FORMS BEST
PRACTICES
By Rendy Del Rosario
SENIOR MOBILE DEVELOPER
.NET DOMINICANA CO-
ORGANIZER
www.xamboy.c
om
@rdelrosario
GitHub.com/rdelros
arioGitHub.com/CrossGeeks
CONTENT
USER INTERFACE USER EXPERIENCE MAINTENANCE
SECURITY PERFORMANCE CUSTOMIZATIONS
USER
INTERFACE
Use SVG for simple icons
Code behind is just for UI
stuff
Take advantage of open
source user interfaces
https://snppts.io/
https://github.com/jsuarezruiz/xamarin-forms-goodlook
DEFINE APPLICATION STYLES
USE TRIGGERS AND CONVERTERS
TO AVOID USING CODE BEHIND
UI COMMANDING PATTERN
USER
EXPERIENCE
Loading/Empty states
Onboarding
Handle Connectivity
Handle Permissions Requests
Cache data (MonkeyCache, Akavache,
etc.)
Animations
Localization awareness
Handle time zone
Relative time
Paging
Offline support (Realm, SQLite)
MAINTENAN
CE
Use an MVVM Framework
Dependency injection
Schedule package upgrades
Unit testing
UI Testing
AppCenter (Analytics, Crash Reporting, CI)
OpenSource Libraries
PERFORMA
NCE
Use HTTPClient with native platform handler
Images optimization
XAML Compilation
Single label better than multiples
Use Fast Renderers
Don't try to make a ListView with ScrollView and StackLayouts
Use IList instead of IEnumerable
Should use await on Push/Pop async
If using a background image for a page use JPG
PERFORMANCE
Use DataTemplates in ListViews
Use control templates
Be aware on unsubscribing when using event handlers
Threading awareness
Avoid using multiple nested layouts instead use Grid
Only use the dependencies you need
SECURITY
Use secure platform storage to
store sensitive data
Obfuscate code
Use HTTPS for requests
https://docs.microsoft.com/en-
us/xamarin/essentials/secure-storage
https://blog.xamarin.com/protecting-xamarin-apps-do
CUSTOMIZATIO
NS
Use effects instead of
custom renderers for
simple customizations
Be aware of custom
renderers lifecycle
REFERENCES
https://docs.microsoft.com/en-us/xamarin/essentials/
https://kent-boogaart.com/blog/jason-smith's-xamarin-forms-
performance-tips
https://www.youtube.com/watch?v=RZvdql3Ev0E
https://www.wintellect.com/xamarin-forms-for-windows-developers-tips-
tricks-and-lessons-learned-part-2/
https://xamgirl.com/universal-styling-in-xamarin-form-apps/
https://xamgirl.com/understanding-converters-in-xamarin-forms/
https://xamgirl.com/custom-renderers-vs-effects-in-xamarin-forms/
https://www.xamboy.com/2018/03/29/sharing-svg-icons-across-
platforms-in-xamarin-forms/
https://romannurik.github.io/AndroidAssetStudio/
QUESTIONS

Xamarin Forms Best Practices