3. Xamarin + Xamarin.Forms
With Xamarin.Forms:
more code-sharing, native controls
Traditional Xamarin approach
Shared UI Code
4. What’s Included
▪ 40+ Pages, Layouts, and Controls
▪ Build from code behind or XAML
!
▪ Two-way Data Binding
!
▪ Navigation
!
▪ Animation API
!
▪ Dependency Service
!
▪ Messaging Center
!
Shared UI Code
9. Model-View-ViewModel
Data
View ViewModel Model
How to display
information
What to display
Flow of interaction
Business Logic
Data objects
Events
Data
17. Extensibility
▪ Custom Renderer
▪ Easily subclass any control you wish to
customize.
▪ Add your own custom controls.
▪ Add custom bindable properties
!!
http://developer.xamarin.com/guides/cross-platform/
xamarin-forms/custom-renderer/
23. Extensibility
▪ Dependency Service
▪ Lets shared code access platform-specific SDK features via an
Interface implementation
▪ B.Pillow Note: This is more commonly know as the “Service Locator”
pattern. Not to be confused with dependency injection.
!!
26. Extensibility
▪ Step 3: Register with Dependency Service
* B.Pillow Note: Finally, add this [assembly] attribute above
the class (and outside any namespaces that have been
defined), including any required using statements.
27. Extensibility
▪ Step 4: Access from shared code
* B.Pillow Note: If you need more than service location/
injection, like full IOC, then there area number of
adapters for Xamarin.Forms for other IOC frameworks.
28. DEMO 3
Stocks App +
Text to Speech
www.github.com/JamesMontemagno/MyStocks.Forms
48. F# And Xamarin.Forms
Need latest version of Xamarin Studio
Need latest F# plugin
No templates yet, so clone this github project and modify the project xml by hand
Use the beta PCL 78 F# Core
Link to the facade assemblies for Monotouch, these vector PCL calls to correct namespaces in
platform dll’s
See this blog post: http://www.knowing.net/index.php/2014/08/27/xamarin-forms-programming-in-f/
If you do the above incorrectly, you will get errors with things like INotifyPropertyChanged not
found, etc.
No “shared projects” for F# yet, for now use combo of native and PCL
49. F# Example
namespace FSXF1
open System
open MonoTouch.UIKit
open MonoTouch.Foundation
open Xamarin.Forms
type App = class
static member GetMainPage =
let lbl = new Label()
lbl.Text <- "Hello, F# Xam.Forms!"
lbl.VerticalOptions <- LayoutOptions.CenterAndExpand
lbl.HorizontalOptions <- LayoutOptions.CenterAndExpand
let cp = new ContentPage()
cp.Content <- lbl
cp
end
[<Register("AppDelegate")>]
type AppDelegate() =
inherit UIApplicationDelegate()
member val Window = null with get, set
// This method is invoked when the application is ready to run.
override this.FinishedLaunching(app, options) =
this.Window <- new UIWindow(UIScreen.MainScreen.Bounds)
Forms.Init()
this.Window.RootViewController <- App.GetMainPage.CreateViewController()
this.Window.MakeKeyAndVisible()
true
module Main =
[<EntryPoint>]
let main args =
UIApplication.Main(args, null, "AppDelegate")
0 (from: http://www.knowing.net/index.php/2014/08/27/xamarin-forms-programming-in-f/)