SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
Presentation at @wpug covering lots of mvvm goodness across all of: iOS, Android, WP7 and WinRT - using the Microsoft and Xamarin tools - vs2010, vs2011, MonoTouch and MonoDroid - and using mvvmCross library for Mvvm and DataBinding
Presentation at @wpug covering lots of mvvm goodness across all of: iOS, Android, WP7 and WinRT - using the Microsoft and Xamarin tools - vs2010, vs2011, MonoTouch and MonoDroid - and using mvvmCross library for Mvvm and DataBinding
12.
@slodge
Mvvm Basics
get/set
Properties
ViewModel
call Commands
ViewModel
Model
View
ViewModel
Whatever C# you
Model
View
like!
Model
View
notify changes
some messaging
14.
@slodge
Mvvm Benefits
• The “normal” reasons:
– Separation of concerns
– Designability (Blendability)
– Testability
• The MvvmCross reason:
– Cross platform code reuse
15.
@slodge
Mvvm Cross Platform
get/set
Properties
ViewModel
call Commands
ViewModel
Model
View
ViewModel
Whatever C# you
Model
View
like!
Model
View
notify changes
some messaging
Platform Specific Shared
33.
@slodge
Inside WP7 App…
• Navigation is mapped to XAML Uri’s – with
parameters put in a JSON object in the path.
• Implementation hidden from the View and
ViewModel.
42.
@slodge
Inside Android App…
• Navigation is mapped to Intent’s– with
parameters put in a JSON object in the Extras.
• Implementation hidden from the View and
ViewModel.
54.
@slodge
Inside iPad App
• The iPad App is actually the iPhone App.
• But the UI is different – take advantage of the
larger screen.
• Achieved in code: IMvxTouchViewPresenter
60.
@slodge
Inside Windows 8 Metro App…
It’s like WP7….
• No C#, just XAML with {Binding}
• ValueConverters are used in Bindings
• Lists are filled using ItemsSource
• BUT: Navigation is achieved through code – not
Xaml Uri’s
61.
@slodge
Inside Windows 8 Metro App
Warnings:
• MvvmCross WinRT implementation
is “first cut”
– e.g. differences in ViewModel lifecycle
• Under-the-hood Win8
implementation is native code –
there are big differences.
– differences in XAML
– differences in .Net/C#
• Everything is async.
62.
@slodge
Inside Windows 8 Metro App…
• Beyond the warnings – look at the numbers!
66.
@slodge
Panoramas, Pivots and Tabs
• Tabbed navigation is another common
metaphor across phones and across ipads too.
• Generally speaking think of each “tab” as its
own ViewModel.
• Binding is then available in each platform.
68.
@slodge
Jump Lists
• Are possible…
• But need separate list
formats on each
platform…
• Thinking about how
best to do this…
• Open to ideas!
69.
@slodge
Dependency Injection
• Useful for testing
• Essential for injecting platform specific services –
e.g:
– Camera capture
– GPS services
– NFC
• MvvmCross wraps OpenNetCF DI – adds some
extension methods:
– RegisterServiceInstance<TService>(instance)
– RegisterServiceType<TService, TServiceType>()
– GetService<TService>()
70.
@slodge
Native Types
• Sometimes #define is necessary…
• Personally, I try to use interfaces and DI
wherever possible.
71.
@slodge
i18n
• Choices:
– Each platform has their own localisation format
available.
– Xamarin are supporting .resx files…
– MvvmCross provides a .json file mechanism
– Or write your own
72.
@slodge
Blendability
• Limited support available right now.
• It’s relatively easy to integrate your own
design time ViewModelLocator with design
time data…
73.
@slodge
Problems?
• WinRT – issues…
• Xcode designer - OMG
• iOS development and debugging is most
painful
• Some compiler differences – JIT
• Multiple “core” project files annoying – and
breaks refactoring
• MvvmCross still changing
75.
@slodge
That’s all folks…
Hopefully we covered:
• C# Cross Platform
• An Mvvm Introduction
• Some Code: TwitterSearch
• Some Extras
There might be time for:
• Q&A