28
www.xam-consulting.com www.michaelridland.com 10 Awesome Xamarin.Forms Tips & Tricks

10 Awesome Xamarin.Forms Tips & Tricks

Embed Size (px)

Citation preview

www.xam-consulting.com www.michaelridland.com

10 Awesome Xamarin.FormsTips & Tricks

www.xam-consulting.com www.michaelridland.com

Michael Ridland

www.michaelridland.com

www.xam-consulting.com www.michaelridland.com

Xamarin Specialists - We work with Xamarin all day and night.

www.xam-consulting.com www.michaelridland.com

Developed Apps WITHOUT Xamarin.Forms

www.xam-consulting.com www.michaelridland.com

Developed Apps WITH Xamarin.Forms

www.xam-consulting.com www.michaelridland.com

I hate Xamarin.Formsbecause of this, this, this and that

www.xam-consulting.com www.michaelridland.com

OK, Xamarin.Forms is not perfect

but it’s a trade off !

www.xam-consulting.com www.michaelridland.com

The 10 Tips and TricksGoal - Get at least 1 tip for everyone in the room!Goal - Tips for both beginners and gurus

www.xam-consulting.com www.michaelridland.com

Tip #1 - Learn from github seriously

▪Download the apps and run them

▪github.com/conceptdev

▪github.com/xamarin

www.xam-consulting.com www.michaelridland.com

Tip #2 - Use the Source

Xamarin.Forms Source (Can use Assembly browser in XS)

XLabs Source

* The #1 documentation for Custom Renderers & Native Code!

www.xam-consulting.com www.michaelridland.com

Tip #3 - Be Patient

▪Mobile is hard, expect to encounter issues and frustrations

▪Estimate accordingly, if you’re used to estimating web projects multiple it by 3-5

▪Xamarin dev is not a walk in the park, but it has good outcomes, eg Fast Native App

www.xam-consulting.com www.michaelridland.com

Tip #4 - Don’t fight the Framework

▪ ‘I want Cancel here because that’s how I do it in iOS’…

▪ ‘I want swipe cell because that’s how I do it in iOS’…

▪ You can build nice UI’s with Xamarin.Forms but you just

need to be within it’s constraints.

▪ You can change your UI to match what’s ‘In the box’

www.xam-consulting.com www.michaelridland.com

Tip #4 - Don’t fight the Framework

It’s 3-10 times more expensive

but you can still do anything that you can do in Native

Once you break-out (custom renderer)

www.xam-consulting.com www.michaelridland.com

Tip #5 - Grid can be Awesome

▪Not difficult to use (nearly as easy as

StackLayout)

▪Works well with XAML (unlike relative)

▪ Faster than StackLayout

▪Can be used to create overlays/

advanced UIs

www.xam-consulting.com www.michaelridland.com

Tip #6 - ListView Performance Tips

▪Step 1 - Use CS over XAML

▪Step 2 - Use Grid/Absolute Layout

▪Step 3 - Try FastCell Implementation (link?)

▪Step 4 - Create a Custom Native Cell

▪Step 5 - Any tips from the crowd?

www.xam-consulting.com www.michaelridland.com

Tip #7 - TaskCompletionSource

▪Many NativeAPIs are based on events/callbacks

▪Use TaskCompletionSource to support async

▪http://www.michaelridland.com/xamarin/taskcompletionsource-xamarin-beautiful-async/

www.xam-consulting.com www.michaelridland.com

Tip #7 - TaskCompletionSource

www.xam-consulting.com www.michaelridland.com

Tip #8 - Bindable Property Template

www.xam-consulting.com www.michaelridland.com

Tip #9 - Forms->Native->Forms - The Xamarin.Forms Holy Grail

▪Take a Xamarin.Forms Views and Convert into

a Native View to use

▪Great for using with Custom Renderers

▪Great for using with Native Components

▪Demo!

www.xam-consulting.com www.michaelridland.com

Tip #10 - Add Xamarin.Forms to your MvvmCross App

▪https://github.com/rid00z/MvvmCrossNavigationDemo

▪Perfect if you already have a MvvmCross application and would like a few Xamarin.Form pages

▪Demo!

www.xam-consulting.com www.michaelridland.com

Bonus Tip - MessagingCentreitis Anti-Pattern

•MessageCentre is Great! •Use it and love it •But don’t overdo it

www.xam-consulting.com www.michaelridland.com

Bonus Tip - App Statics Anti-Pattern

• Using global statics for Navigation in your App

• It’s a recipe for a big ball of mud

• It’s easy to begin with - but in the end all your code becomes tightly

coupled

Bad - Don’t do this!

www.xam-consulting.com www.michaelridland.com

Bonus Tip - App Statics Anti-Pattern

• The solution! - Use a MvvmFramework with a Navigation Service

Good - Do this!

www.xam-consulting.com www.michaelridland.com

Bonus Tip - Run Sync

• Once in a while you might need to run a async function

synchronously. (For a Native API/Component)

www.xam-consulting.com www.michaelridland.com

www.xam-consulting.com www.michaelridland.com

Bonus Tip - Easy dialogs with Acr-Userdialogs

Easily add Alerts/Prompts/Loading Dialogs using Acr

UserDialogs (https://github.com/aritchie/acr-xamarin-

forms)

- It’s in nuget

www.xam-consulting.com www.michaelridland.com

All Code and Links will be put into a Blog post on

www.michaelridland.com

If you want it today please ask me for it!

www.xam-consulting.com www.michaelridland.com

Q & AMichael [email protected]

www.michaelridland.com