MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF
eBook - ePub

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF

  1. 490 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF

About this book

In Detail

MVVM (Model View View Model) is a Microsoft best practices pattern for working in WPF and Silverlight that is highly recommended by both Microsoft and industry experts alike. This book will look at the reasons for the pattern still being slow to become an industry standard, addressing the pain points of MVVM. It will help Silverlight and WPF programmers get up and running quickly with this useful pattern.

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF will help you to choose the best MVVM approach for your project while giving you the tools, techniques, and confidence that you will need to succeed. Implementing MVVM can be a challenge, and this book will walk you through the main issues you will come across when using the pattern in real world enterprise applications.

This book will help you to improve your WPF and Silverlight application design, allowing you to tackle the many challenges in creating presentation architectures for enterprise applications. You will be given examples that show the strengths and weaknesses of each of the major patterns. The book then dives into a full 3 tier enterprise implementation of MVVM and takes you through the various options available and trade-offs for each approach. During your journey you will see how to satisfy all the demands of modern WPF and Silverlight enterprise applications including scalability, testability, extensibility, and blendability.

Complete your transition from ASP.NET and WinForms to Silverlight and WPF by embracing the new tools of these platforms, and the new design style that they allow for. MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF will get you up to speed and ready to take advantage of this powerful new presentation platform.

Approach

This book combines practical, real-world examples with all the background material and theory you need The concepts are explained with a practical LOB enterprise application that is gradually built through the course of this book. MVVM offers lots of design choices and the author shows examples of each of these approaches, by changing the code to achieve the same results.

Who this book is for

This book will be a valuable resource for Silverlight and WPF developers who want to fully maximize the tools with recommended best practices for enterprise development. This is an advanced book and you will need to be familiar with C#, the .Net framework, and Silverlight or WPF.

Trusted by 375,005 students

Access to over 1.5 million titles for a fair monthly price.

Study more efficiently using our study tools.

Information

Year
2012
Edition
1
eBook ISBN
9781849683425

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF


Table of Contents

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Instant Updates on New Packt Books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Presentation Patterns
The Project Billing sample application
Types of state
History of presentational patterns
Monolithic design
The problems with monolithic design
Code maintenance
Code structure
Code testability
Data service stub
Monolithic Project Billing sample
ProjectsView
Initialization
Event handlers
Helpers
Running the sample
Takeaways
Poor testability
Poor extensibility and code reuse
Rapid application development
RAD Project Billing sample
Takeaways
MVC
View
Controller
Model
Layered design
The layers
Presentation layer
Business layer
Data layer
MVC with layered design
MVC Project Billing sample
Model
Controller
View
Initialization
Event handlers
Helpers
MainWindow
How it works
Takeaways
Memory leaks
MVP
MVP Project Billing sample
Model
View
Event handlers
Public methods
Helpers
Presenter
Event handlers
Helpers
Main window
How it works
Takeaways
Summary
2. Introduction to MVVM
History
Structure
Pure MVVM
View
View Model
WPF and Silverlight enablers
Dependency Properties
Dependency property inheritance
Data context
Attached behavior pattern
Rich data binding
INotifyCollectionChanged and ObservableCollection<>
Automatic dispatching
Triggers
Styles
Control Templates
Data templates
Commands
MVVM project billing sample
MVVM design
View Models
ProjectsViewModel
ProjectViewModel
Model
Code
ProjectsModel
ProjectViewModel
ProjectsViewModel
WPF UI
ProjectsView
MainWindow
Silverlight UI
Porting assemblies to Silverlight
ProjectsView
MainPage
Benefits of MVVM
MVVM and humble views
Issues and pain points of MVVM
MVVM Light
Summary
3. Northwind — Foundations
Northwind requirements
Presentation tier foundation
Locator pattern
Data access tier
Listing the customers
Unit testing getting customers
Using an isolation framework
Adding tabs
Viewing customer details
Viewing details for one customer
Testing CustomerDetailsViewModel
Wiring up the customer list box
Testing ShowCustomerDetails()
Summary
4. Northwind—Services and Persistence Ignorance
Adding a Service Layer
Integrating the Service Layer
Persistence ignorance and custom models
Trade-offs of generated models
Adding persistence ignorance
Adding unit tests
Summary
5. Northwind—Commands and User Inputs
Pure MVVM
Making it easier with frameworks
Updating customer details
Testing and updating customer details
Gestures, events, and commands
InputBindings
KeyBinding
MouseBinding
Using code behind
Event to command
Attached Behavior
Using MVVM Light
Summary
6. Northwind—Hierarchical View Model and IoC
Adding orders to customer details
Service layer
Application layer
Presentation layer
View Models
Views
Take aways
Viewing order details
ToolManager
Inversion of Control frameworks
IoC designs
Service Locator anti-pattern
IoC best practices
Adding an IoC container to Northwind
Order details
Summary
7. Dialogs and MVVM
Should we make a compromise?
Dialog service
Using DataTemplates with DialogService
Convention over configuration
Mediators
Attached behaviors
Summary
8. Workflow-based MVVM Applications
WF for business rules execution
Handling delays in rules execution
Using WorkflowInvoker in background thread
Using WorkflowApplication
WF for controlling application flow
Summary
9. Validation
Validations and dependency properties
Error templates
Validation in MVVM-based applications
Validation rules
Using validation rules
Specializing validation rules—supporting parameters
Validation rules and converters
Validation mechanism in WPF and Silverlight
IDataErrorInfo
Validation states
Providing a summary validation error
Invalidating multiple fields
Limitations and gotchas
INotifyDataErrorInfo
Enterprise library validation application block
Complex business rules
Error notifications
Error message box
Highlighting fields
Error messages in the tooltip
Error messages beside the control
Validation summary pane
Flip controls
Summary
10. Using Non-MVVM Third-party Controls
Using attached behaviors
Using binding reflector
readonly CLR properties (with no change notification support)
Using .NET 4.0 dynamic
Using MVVM adapters
Summary
11. MVVM and Application Performance
Asynchronous binding
Asynchronous View Model construction
Priority binding
Virtualization and paging
Using BackgroundWorker
Targeting system configuration
Event Throttling
Lazy Initialization
Summary
A. MVVM Frameworks
B. Binding at a Glance
Basics
Validation
ValidationRules
IDataErrorInfo
INotifyDataErrorInfo [.net 4.5]
Enterprise Library 5.0 Validation Application Block
Windows WF
Validation.ErrorTemplate
Static properties/fields
Executing code in DataContext
Binding to DataContext[DC]
Resources
Types with default constructor
XmlDataProvider
ObjectDataProvider
Binding to resource
Static resource
Dynamic resource
Updating source
Binding.UpdateSourceTrigger
Binding.Delay: [.net 4.5] [Binding.Mode:TwoWay / OneWayToSource ]
Mode [Binding.Mode] [T:Target, S:Source]
Binding to other elements in the view
ElementName
RelativeSource
Conversion
Binding.StringFormat [SF]
Converter [C]
Performance
Async binding
ObjectDataProvider.IsAsynchronous
PriorityBinding
Index

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF

Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: August 2012
Production Reference: 1010812
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84968-342-5
www.packtpub.com
Cover Image by Tony Shi ( )

Credits

Authors
Ryan Vice
Muhammad Shujaat Siddiqi
Reviewer
Kanishka (Ken) Abeynayake
Acquisition Editor
Dhwani Devater
Lead Technical Editor
Dhwani Devate...

Table of contents

  1. MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.5M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1.5 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF by Ryan Vice, Muhammad Shujaat Siddiqi in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Tecnología de la información. We have over 1.5 million books available in our catalogue for you to explore.