Prism in Xamarin Forms
from Zero to Hero
Hello World!
Charlin Agramonte
charlin@crossgeeks.com
Twitter: @chard003
xamgirl.com
Rendy Del Rosario
rendy@crossgeeks.com
Twitter: @rdelrosario
xamboy.com
What’s Xamarin Forms
An open source mobile UI framework
from Microsoft for building
iOS, Android, & Windows apps with .NET
from a single shared codebase.
Frameworks we can use
▸ Prism
▸ MvvmCross
▸ FreshMvvm
▸ Mvvm Light
▸ Reactive UI
What’s
Prism?
▸ Loosely coupled
▸ Maintainable
▸ Testable applications
Why Prism?
Some of Prism Features
include:
▸ MVVM
▸ Navigation
▸ Events
▸ Commanding
▸ Modules
▸ Alerts
▸ Dependency Injection
How to Set
Up?
1. Select a DI container
▸ Unity
▸ Autofac
▸ Ninjec
▸ Dryloc
Reference - XamGirl Guide:
https://xamgirl.com/prism-in-xamarin-f
orms-step-by-step-part-1/
2. Install Nuget Package
3. Update App.xaml.cs
Reference - XamGirl Guide:
https://xamgirl.com/prism-in-xamarin-f
orms-step-by-step-part-1/
3. Update App.cs
Reference - XamGirl Guide:
https://xamgirl.com/prism-in-xamarin-f
orms-step-by-step-part-1/
4. Add Platform Initializer
Android
Reference - XamGirl Guide:
https://xamgirl.com/prism-in-xam
arin-forms-step-by-step-part-1/
5. Add Platform Initializer iOS
Reference - XamGirl Guide:
https://xamgirl.com/prism-in-xam
arin-forms-step-by-step-part-1/
Live
Prism DEMO
Let's get to coding!
Project
Structure
Connecting
View and
ViewModels
2 ways to do it
1-Specifying the ViewModel associated
2-Do it by convention
Prism
Navigation
Relative
Absolute
Use the Prism Navigation Service in
your ViewModel
Live
Prism DEMO
Let's get to coding!
Passing
Parameters
Using Navigation Parameters
Using QueryString
INavigatedAware
Get your param
Go Back
You can pass parameters
Display an
alert
Inject the IPageDialogService
Bindable base
Delegate
Commands
Pre-registered services
▸ INavigationService
▸ IPageDialogService
▸ IEventAggregator
▸ IDeviceService
Services
1-Create an
interface
2-Create your
service
4-inject it
3-Register it
Events
1-Create
2-Inject it
3-Subscribe
4-Send
Modules
Prism Good
Practices
▸ Don’t use hardcoded string for
navigation
▸ Avoid using Xamarin Forms namespace
in the ViewModels
▸ Make sure to use IDestructible to
unsubscribe to any events/viewmodel
cleanup
▸ Use a BaseViewModel
▸ Don’t use static/singleton instance
inside viewmodel code
THANKS!
Any questions?
You can find us at @chard003 | @rdelrosario
References
▸ Brian Lagunas Blog:
http://brianlagunas.com/
▸ XamGirl Prism Guides:
https://xamgirl.com/prism-in-xamarin-forms-step-by-st
ep-part-1/
▸ Prism Library Github Repo:
https://github.com/PrismLibrary/Prism

Prism in xamarin forms from zero to hero