In this session we introduced the MvvmCross open source framework for Xamarin and talk about how can it help you build clean and polished apps without compromise.
It doesn’t matter if you use traditional Xamarin or Xamarin.Forms (spoiler: MvvmCross supports both!).
Some of the topics include:
- MVVM pattern
- Why to use an MVVM framework?
- IoC, DI
- Data Bindings
- Converters
- Navigation
- ViewPresenters
- And more!
9. Features in a nutshell
▣ ViewModel first Navigation
▣ Data Bindings, Commands and Converters
▣ IoC Container / DI engine
▣ Platform specific widgets
▣ Unit Test Helpers
▣ Plugins
▣ Complete flexibility!
12. Navigation in MvvmCross
▣ All logic remains in the shared code
▣ ViewPresenters for each platform
▣ Presentation attributes for declaration
▣ Presentation Hints for behavior
▣ 100% customizable
13. Navigation in MvvmCross
public class RootViewModel : MvxViewModel
{
private readonly IMvxNavigationService _navigationService;
public RootViewModel(IMvxNavigationService navigationService)
{
_navigationService = navigationService;
}
private async Task OpenModalAsync()
{
await _navigationService.Navigate<ModalViewModel>();
}
}
16. Data Bindings in MvvmCross
▣ Support for .cs, .xml, .axml, .xaml
▣ Value Converters
▣ Value Combiners
▣ OneWay, TwoWay, OneWayToSource, OneTime
▣ Multiple syntaxes
▣ Support for custom bindings
17. Data Bindings in MvvmCross
▣ Bindings in .axml (Tibet):
local:mvxBind=“Text MyTextProperty”
local:mvxBind=“Click MyAwesomeCommand”
local:mvxBind=“Checked Inverse(Prop), Mode=TwoWay,
Fallback=False”
18. Data Bindings in MvvmCross
▣ Bindings in xaml (Tibet):
mvx:Bi.nd="Text MyTextProperty”
mvx:Bi.nd=“Click MyAwesomeCommand”
mvx:Bi.nd=“Checked Inverse(Prop), Mode=TwoWay,
Fallback=False”
19. Data Bindings in MvvmCross
▣ Bindings in .cs (Fluent):
set.Bind(MyLabel).For(v => v.Text).To(vm => vm.MyProperty);
set.Bind(MyButton).To(vm => vm.MyAwesomeCommand);
set.Bind(MySwitch)
.For(v => v.On)
.To(vm => vm.Prop)
.WithConversion<InverseConverter>()
.WithFallback(false);
21. IoC Container and DI engine
▣ It’s optional
▣ Service Locator / IoC
▣ Constructor and Property Dependency Injection
▣ Singletons, dynamics, Open Generics, Child
Containers
▣ Bulk registrations
▣ What if I prefer to use $Lib$ instead? Also possible!
22. IoC Container and DI engine
Source: https://xamarinhelp.com/ioc-container-performance/
24. Platform specifics
▣ Support for Android.Support packages
▣ Polymorphic lists made easy
▣ Support for background services / push
notifications
▣ iOS Side Menu
▣ Abstraction plugins for most common features
25. Plugins
▣ Small code pieces that resolve specific situations
▣ Install from NuGet -> Run
▣ Official Plugins: Accelerometer, Visibility, Json,
Color, Localization, Messenger, Email, …
▣ Loads of 3rd party plugins
27. Resources & Documentation
mvvmcross.com
Where our official
documentation lives
github.com/MvvmCross
Official samples and
source code
Slack
xamarinchat.herokuapp.
com. Then join
#mvvmcross
StackOverflow
Ask using the
#mvvmcross tag
Xamarin Forums
Use the official forums
Twitter
Follow and don’t
hesitate to contact
influencers
28. Get involved!
Support us on
OpenCollective
Contribute on
GitHub
Blog about your
experiences
Use the framework
in your apps