Download presentation
Presentation is loading. Please wait.
Published byGodwin Lawrence Modified over 8 years ago
1
/DEV/TM #1 Building Cross-Platform Apps with Xamarin and MvvmCross Flavius-Radu DEMIAN
2
Xamarin’s Unique Approach
4
Code Sharing Techniques
5
portable class libraries (PCL) partial classes compiler conditional blocks shared projects
6
Xamarin Architecture Guide
7
Demo Time
8
What is MVVM?
10
MVVM Technical Details properties data binding INotifyPropertyChanged INotifyCollectionChanged IValueConverter ICommand UI thread
11
Why MVVM?
12
MVVM Pros and Cons Pros: separation of concerns decoupling code reuse testability Cons: MVVM is “overkill” for simple UI operations
13
The MvvmCross Magic
14
It’s an open-source framework maintained by Stuart Lodge & Co. It has Dependency Injection built-in -> Interface Driven Design. It has a lot of plugins already written such as location, emails, gallery, network, SQLite, secure storage, phone calls etc. #IF plugins -> less work for the developer, but also less control.
16
The MvvmCross Magic MvvmCross has support for: Xamarin.iOS Xamarin.Mac Xamarin.Android Windows Phone and Windows 8 Windows Presentation Foundation Universal Windows Platform
17
The MvvmCross Magic Is has huge popularity and the community is very active https://jabbr.net/#/rooms/mvvmcross https://github.com/MvvmCross/MvvmCros s https://github.com/MvvmCross/MvvmCros s https://xamarinchat.slack.com/messages/ mvvmcross/ https://xamarinchat.slack.com/messages/ mvvmcross/
18
MVVMCross – Dev Flow 1. Create Services – ‘Back end’ – PCL.cs 2. Create ViewModels – PCL.cs 3. Create Views.AXML - Mono for Android – (tablet and) phone.XIB and.cs - MonoTouch for iOS – iPad and iPhone.XAML – WP8 and WinRT
19
Data Binding, Commands, Navigation
20
MVVM Cross - Binding
21
Data Binding - Properties No C#, just XAML
22
Data Binding - Properties No C#, just XML xmlns:local="http://schemas.android.com/apk/res-auto" <EditText local:MvxBind="Text Password"
23
Data Binding - Properties Just C# var set = this.CreateBindingSet (); set.Bind(textField_Password).To(vm => vm.Password);
24
ViewModel Collection Property
25
UI Syntax
27
Data Binding - Listviews No C#, just XAML <ListBox ItemsSource="{Binding MyCollection}" …..
28
Data Binding - Listviews No C#, just XML <Mvx.MvxListView local:MvxBind="ItemsSource MyCollection; ItemClick ViewDetailsCommand" local:MvxItemTemplate="@layout/item_template_row" />
29
Data Binding - Listviews Just C# var set = this.CreateBindingSet (); set.Bind(source).To(x => x.MyCollection); set.Apply();
30
MVVMCross - Converter
33
ViewModel Command
34
MVVMCross - Command
35
ViewModel Commands No C#, just XAML xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:commandbinding="clr- namespace:Cirrious.MvvmCross.WindowsPhone.Commands;assembly=Cirrious.MvvmCross.WindowsPhone"
36
ViewModel Commands No C#, just XML xmlns:local="http://schemas.android.com/apk/res-auto"
37
ViewModel Commands Just C# var set = this.CreateBindingSet (); set.Bind(btn_Login).To(x => x.LoginCommand); set.Apply();
38
Navigation Go forward CurrentViewModelInstance.ShowViewModel ();
39
Navigation Go back CurrentViewModelInstance.Close(this);
40
MvvmCross App Architecture
41
App Architecture The project should be split in (at least) two parts: 1. Common Core which contains: Models Viewmodels Business logic Data Access Layer 2. UI-project per platform: Each platform views Demo Time
42
MvvmCross Pros & Cons Pros: interchangeable code module supports Test Driven Development (TDD) it follows the Core pattern it has data binding
43
MvvmCross Pros & Cons Cons: it is a non-native pattern for iOS – MVC- and Android –aprox MVC- core 3 rd party dependency lot’s of glue code for custom bindings
44
Xamarin Pros & Cons Pros: native experience you can use a lot of components that.NET developers already use shared code base only one programming language
45
Xamarin Pros & Cons Cons: you need a Mac It has a license fee per developer, per platform -> $$$ bugs can appear: https://bugzilla.xamarin.com/https://bugzilla.xamarin.com/ C# is needed
48
Thank you! A big thanks to Cloudbase! #theCodeAwakens Flavius-Radu DEMIAN
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.