MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF
Formats:
save 15%!
save 37%!
Free Shipping!
| Also available on: |
|
- Build an enterprise application using Silverlight and WPF, taking advantage of the powerful MVVM pattern, with this book and e-book
- Discover the evolution of presentation patterns—by example—and see the benefits of MVVM in the context of the larger picture of presentation patterns
- Customize the MVVM pattern for your projects’ needs by comparing the various implementation styles
Book Details
Language : EnglishPaperback : 490 pages [ 235mm x 191mm ]
Release Date : August 2012
ISBN : 1849683425
ISBN 13 : 9781849683425
Author(s) : Ryan Vice, Muhammad Shujaat Siddiqi
Topics and Technologies : All Books, Microsoft Development , Architecture & Analysis, Enterprise, Microsoft, Microsoft Silverlight
Table of Contents
PrefaceChapter 1: Presentation Patterns
Chapter 2: Introduction to MVVM
Chapter 3: Northwind—Foundations
Chapter 4: Northwind—Services and Persistence Ignorance
Chapter 5: Northwind—Commands and User Inputs
Chapter 6: Northwind—Hierarchical View Model and IoC
Chapter 7: Dialogs and MVVM
Chapter 8: Workflow-based MVVM Applications
Chapter 9: Validation
Chapter 10: Using Non-MVVM Third-party Controls
Chapter 11: MVVM and Application Performance
Appendix A: MVVM Frameworks
Appendix B: Binding at a Glance
Index
- Chapter 1: Presentation Patterns
- The Project Billing sample application
- Types of state
- History of presentational patterns
- Monolithic design
- The problems with monolithic design
- Data service stub
- Monolithic Project Billing sample
- ProjectsView
- Running the sample
- Takeaways
- Rapid application development
- RAD Project Billing sample
- Takeaways
- MVC
- View
- Controller
- Model
- Layered design
- The layers
- MVC with layered design
- MVC Project Billing sample
- Model
- Controller
- View
- How it works
- Takeaways
- Memory leaks
- MVP
- MVP Project Billing sample
- Model
- View
- Presenter
- Main window
- How it works
- Takeaways
- Summary
- Chapter 2: Introduction to MVVM
- History
- Structure
- Pure MVVM
- View
- View Model
- WPF and Silverlight enablers
- Dependency Properties
- Dependency property inheritance
- Rich data binding
- INotifyCollectionChanged and ObservableCollection<>
- Automatic dispatching
- Triggers
- Styles
- Control Templates
- Data templates
- Commands
- MVVM project billing sample
- MVVM design
- View Models
- Model
- Code
- ProjectsModel
- ProjectViewModel
- ProjectsViewModel
- WPF UI
- Silverlight UI
- Benefits of MVVM
- MVVM and humble views
- Issues and pain points of MVVM
- MVVM Light
- Summary
- Chapter 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
- Chapter 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
- Chapter 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
- Chapter 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
- Adding an IoC container to Northwind
- Order details
- Summary
- Chapter 7: Dialogs and MVVM
- Should we make a compromise?
- Dialog service
- Using DataTemplates with DialogService
- Convention over configuration
- Mediators
- Attached behaviors
- Summary
- Chapter 8: Workflow-based MVVM Applications
- WF for business rules execution
- Handling delays in rules execution
- WF for controlling application flow
- Summary
- Chapter 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
- 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
- Chapter 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
- Chapter 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
- Appendix 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
Ryan Vice
Muhammad Shujaat Siddiqi
Code Downloads
Download the code and support files for this book.
Submit Errata
Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.
Errata
- 11 submitted: last submission 09 May 2013Errata type: Code | Chapter number: 1 | Errata date: 15 Oct 2012
In the Section, "Project View" you will need to also add the reference: using System.Windows.Controls.Primitives; This is because it is need to add the UniformGrid in the AddControlsToWindow() method. In the Section "Helpers" you have the following statement LoadProjects method: foreach (Project project in new DataServiceStub().GetProjects()) Shouldn't this be: foreach (Project project in new DataAccess.DataService().GetProjects()) In the method SetEstimateColor() you have the following statements: this.estimateTextBox.Foreground = _actualTextBox.Foreground; this.estimateTextBox.Foreground = Brushes.Green; this.estimateTextBox.Foreground = Brushes.Red; These statements should be: this._estimateTextBox.Foreground = _actualTextBox.Foreground; this._estimateTextBox.Foreground = Brushes.Green; this._estimateTextBox.Foreground = Brushes.Red; The project ProjectBilling.Monolithic will not compile without these changes.
Errata type: Others | Page number: 96 | Errata date: 29-10-2012
The third paragraph on the page should read:
Projects: An ObservableCollection
Projects: An ObservableCollection
Errata type: Others | Page number: 159 | Errata date:29-10-2012
These 2 lines of code under step 4 should be highlighted:
Tools.Add(new AToolViewModel());
Tools.Add(new BToolViewModel());
Errata type: Others | Page number: 171 | Errata date: 29-10-2012
In Step 3, it's helpful to note that this is also due to previously setting UpdateSourceTrigger=PropertyChanged on the textbox when we bound it to the company name in the user control's markup; removing this would break the change notification of EF as well.
Errata type: Others | Page number: 176 | Errata date: 18 Dec 08
Step 2 should be:
and a .NET reference from Northwind.Service to System.Data.Entity
instead of:
and a .NET reference from System.Data.Entityto Northwind.Data.
Errata type: Others | Page number: 196 | Errata date: 29-10-2012
In the second block of code on the page, in the GetCustomer() method, the logic is such that we find the customer from the _customers list then translate the DTO to a model object, however this logic is based on the (big) assumption that GetCustomers() is always called before the GetCustomer() method. It's better to do a simple check for the _customers list before searching it:
if( _customers == null)
GetCustomers();
This way, if we want to add some other functionality somewhere else on the program, where we don't necessarily retrieve the list of Customers first, we won't encounter an error while trying to retrieve a single customer instance.
Errata type: Others | Chapter number: 1 | Errata date: 26 Dec 12
In chapter 1, heading: History of presentational patterns=>Mvc, the following must be made public in order for the solution to work:
public Project Project { get; set; }
The code originally reads (in the book):
MVC Project Billing sampleModel
public Project Project { get; set; }
So MVC Project Billing sampleModel&rdquo should be a comment
Errata date: 11 Jan 2013
In chapter 2 “Introduction to MVVM”, Subchapter “WPF and Silverlight Enablers”, Section: “Dependency Properties”,the object herarchy for WPF should be: ( See also http://msdn.microsoft.com/en-us/library/system.windows.uielement(v=VS.85).aspx)
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
Errata type: Code| Page number: 103 | Errata date: 13-1-2013
IProjectsViewModel SelectedProject should read: IProjectViewModel SelectedProject
Errata type: Code| Page number: 11 | Errata date: 3-1-2013
The following must be made public in order for the solution to work:
public Project Project { get; set; }
The code originally reads (in the book):
MVC Project Billing sampleModelpublic Project Project { get; set; }
MVC Project Billing sampleModel” should be a comment
Errata type: Code| Page number: 205-206 | Errata date: 30-4-2013
The Command.cs file as shown on p205 will not compile due to the method signatures of the Action<> and Func<> delegates. Following are the (commented) errors and corrected lines. //private readonly Action
Sample chapters
You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.
- Maximize separation of concerns by taking advantage of WPF and Silverlight’s rich binding system, templates, and commanding infrastructure
- Discover the built-in support for MVVM in Entity Framework and WCF
- Create unit testable user interfaces the MVVM way
- Work in parallel with minimal dependencies by creating blendable architectures
- Solve common MVVM problems both with and without frameworks depending on your preference
- Extend your architecture and test it by using inversion of control frameworks
- Tackle complex designs by using hierarchical view model design and mediators
- Reduce the amount of code in your user interface by letting the WPF and Silverlights binding system eliminate your need to do things like casting controls and dispatching
- Best practices for dealing with collections
- Create designs that allow for dramatically changing your user interface without having to change code outside the view using data templates
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.
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.
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.

