A refactored version of Xaminals (a Xamarin Sample App), demonstrating ViewModel-First navigation with ZenMvvm. ZenMvvm is a Lightweight ViewModel-First MVVM framework for Xamarin.Forms.
Tip: Search for
//ZM
in the solution to quickly jump to code comments explaining ZenMvvm => click here to do this now
When browsing the code, look for:
- Simple. Almost nothing new to learn. Design pages as you normally would using Xamarin Forms.
- Cleaner, easier to understand architecture compared with Xaminals.
- Nothing in the code-behind files
- ViewModels don't have a dependency on Xamarin.Forms
- Buit-in dependency injection uses the convenient "Smart Resolve" feature meaning you don't have to register dependenices (perfect for rapid prototyping).
- Passing data to another viewmodel is easy. Example below passes an Animal object to the AnimalDetailViewModel:
await navigationService.GoToAsync($"details", animal);
For another sample app, see ZenMvvm Sample App which showcases more features, including navigation with PushAsync<TViewModel>()
.