Build Windows 10 UWP MVVM Apps with Prism Brian Noyes @briannoyes, brian.noyes@gmail.com Slides and Demos: http://noyes.me/1NminLq
Visual Studio Connections About Brian Noyes CTO and Co-founder, Solliance www.solliance.net Microsoft Regional Director Microsoft MVP Pluralsight author www.pluralsight.com Web API Insider, Windows Azure Insider, Window Store App Insider, C#/VB Insider t e brian.noyes@solliance.net @briannoyes http://briannoyes.net Updates will be available at http://www.devconnections.com/updates/LasVegas_Fall08/VS
UI Separation Patterns Goals Architectural goals Loose coupling Separation of concerns Leads to Maintainability Testability Extensibility Putting all your logic here is not good enough
Prism Overview Framework for building XAML apps OSS Maintainable Testable Extensible OSS Current XAML Targets WPF Windows 10 UWP Xamarin Forms
Prism Versions 2008 2009 2010 2011 2012 2013 2014 2015 2016 Prism 1.0 Prism 2.0 Prism 4.0 Prism 5 Prism 6 for WPF (OSS) Prism 2.1 Prism 4.1 Prism 2.2 MVVM PubSub Events PubSub Events Prism 6 for UWP (OSS) Prism for Windows Runtime Prism for Universal Apps
Prism 6 for UWP Relation to Previous Releases Direct port of the Prism for Windows Runtime (Win8/8.1) versions of Prism Some reorganization and renaming Enhancements to leverage some new UWP features and design guidance
Prism for UWP Key Features MVVM + Extensible Application Structuring Well defined abstractions for different kinds of presentation layer code Views, ViewModels, Models, Bootstrapping, Dependency Injection Communications Loosely coupled communications with events and commands Navigation Layers on top of native UWP navigation and integrates it into the MVVM pattern State Management Lets you identify cached transient objects that you want to have automatically restored when app restarts from suspension and termination Validation Includes a reusable infrastructure for data input validation that ties into data binding and MVVM well
MVVM Structuring View Data Binding ViewModel Model Model Object Model Client Services
MVVM Principals Model View ViewModel Data structures and logic to provide data for presentation View Just the structure of what the user sees on the screen Static and dynamic ViewModel Provides data to the view for binding / presentation Wrapped or exposed model objects Client application state Interaction logic
Prism MVVM Support Commands INotifyPropertyChanged support PubSubEvents InvokeCommandAction InteractionRequest ViewModelLocator
ViewModelLocator Consolidates MVVM hookup responsibilities Select a ViewModeltype to go with a View type that is being loaded Create an instance of that ViewModeltype View.DataContext= ViewModel Convention-based by default Views live in .Views child namespace ViewModelslive in .ViewModels child namespace ViewModelname = View name + “ViewModel” Uses ViewModeldefault constructor Can override View type to ViewModeltype mapping Provide default factory for all ViewModeltypes Provide factory method for individualViewModeltypes
MVVM and UWP Navigation Page Page ViewModel ViewModel INavigationService FrameNavigationService Frame
Application Lifecycle Management UWP application lifecycle states: Not Running Running Suspended ClosedByUser Terminated Not Running Launch Running Launch Launch Switch Back Switch Apps Terminated Suspended ClosedByUser Low Memory Shutdown
Validation UI
Prism Validation Support BindableValidator Manages a collection of errors per property for a data object Raises events when the errors change to support data binding Can evaluate DataAnnotations automatically ValidatableBindableBase Derives from BindableBase Contains a BindableValidator Exposes errors for data binding Triggers validation when properties change HighlightXYZOnErrors behaviors Attached behaviors to show a red box on control when there are errors associated with the bound property
Resources e t Github.com/prismlibrary Pluralsight brian.noyes@solliance.net @briannoyes http://briannoyes.net Resources Github.com/prismlibrary Pluralsight Building Windows Store Business Apps https://app.pluralsight.com/library/courses/building-windows-store-business-applications-prism/table-of-contents https://msdn.microsoft.com/en-us/library/windows/apps/xx130643.aspx Slides and Demos: http://noyes.me/1NminLq
Please use Event Board to fill out a session evaluation. Questions? Please use Event Board to fill out a session evaluation. Thank you!