XamarinOne platform to rule them all?
Erwin de Groot @ 040 coders
.NET frameworks
.NET
framework
WPF UI
Libraries
.NET
Silverlight
Xamarin.
Mac
.NET Core
Mono
Touch
Xamarin.
iOS
Mono
Android
Xamarin.
Android
SL UI
Libraries
UWP UI
Libraries
iOS UI
Libraries
Android UI
Libraries
…
MacOS UI
Libraries
.NET standard
.NET
framework
WPF UI
Libraries
.NET
Silverlight
Xamarin.
Mac.NET Core
Xamarin.
iOS
Xamarin.
Android
SL UI UWP UI iOS UI Android UI MacOS UI
.NET standard interface
Xamarin Forms
Xamarin
Forms
Xamarin.
Mac.NET Core
Xamarin.
iOS
Xamarin.
Android
UWP
Shared
UI
iOS Android macOS
Mono &
GTK#
Linux
Xamarin
Xamarin history
Xamarin & alternatives
C#, XAML C++, QML C#, UnityScript, Boo Javascript, HTML5, CSS3
Open source MIT license Open source (L)GPL Proprietary Open source Apache
License
- Still maturing - No native controls - Focus on games
- No native controls
- Slow UI
- No native controls
+ Customizable native
controls
+ Mature rich UI
development
+ Great for games/3D + Fast development
Visual Studio Xamarin Solution
From WPF to Xamarin.Forms
WPF Xamarin.Forms
Control Templates Rendering classes
WPF names:
UserControl
StackPanel
ScrollViewer
DataContext
Xamarin.Forms names:
ContentView
StackLayout
ScrollView
BindingContext
Extended Binding functionality Basic Binding functionality
ComboBox Picker
ToolTips, Menu, ContextMenu -
Xam
ari
n
Bin
din
gs
Xam
ari
n.F
orm
s
User Interface rendering
UWP
StackPanel
Button
Android
LinearLayout
Button
iOS
UIStackView
UIButton
macOS
NSStackView
NSButton
StackLayout
Renderer
Button
Renderer
StackLayout
Renderer
Button
Renderer
UI (XAML)
StackLayout
Button
StackLayout
Renderer
Button
Renderer
StackLayout
Renderer
Button
Renderer
Custom renderers
Custom renderers
Xamarin.Forms.DependencyService
Xamarin.Forms.DependencyService
Xamarin.Forms.DependencyService
Xamarin.Forms.DependencyService
My development setup
Laptop
- Visual Studio Community
- Android emulatorsiPhone SE
Mac mini
- Visual Studio for Mac
- iOS emulators
iPad Air 2
Android phone
(borrowed)
Encountered issue #1
Deploying app to a device or simulator yields:
“Couldn't connect to logcat, GetProcessId returned: 0”
No idea what causes this, but when you uninstall the app
from the device/simulator and try again, it works.
Encountered issue #2
Dunno. Try again.
Encountered issue #3
Latest Xamarin doesn’t support old .net standard anymore.
Increase the ‘minimum supported windows version’ in the
UWP app.
Encountered issue #4
.NET and Java each have their own garbage collection.
What happens when you process a bunch of large (native)
bitmaps?
Call ‘Dispose()’ on the bitmap when not used anymore, or
use the ‘using’ construct. Listen to the ‘OnTrimMemory’
event and invoke the .NET Garbage Collection yourself.
.NET Java
Encountered issue #5
Compiler keeps complaining that the iOS app requires a
LaunchScreen, but the LaunchScreen is there!
‘iPad multitask’ is a new option starting from iOS 11 and
also happens to be enabled default. Somehow this causes
the strange ‘LaunchScreen’ error. Simply disable the option.
Encountered issue #6
Xamarin.Forms 3.3.0 and up: removing a custom control
from the macOS page causes a NullReferenceException.
Issue is known, but not solved yet.
Revert back to Xamarin.Forms 3.2.0
SkiaSharp 1.60.3 and older: when a canvas has size 0x0, an
OutOfMemoryException occurs
Upgrade SkiaSharp to 1.68.0
SkiaSharp 1.68.0 requires Xamarin.Forms 3.3.0
In conclusion: did Xamarin help?
• Flexibility
• Custom renderers
• DependencyService
• A single UI definition
• Once set-up, quickly add features too all platforms.
• Xamarin.macOS hasn’t matured yet
• Open source so you can fix it yourself
• Xamarin & community are pretty fast picking up issues
• Visual differences between platforms sometimes look awkward
• You really need those custom renderers