You are previewing MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF.
O'Reilly logo
MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF

Book Description

If you’re using Silverlight and WPF, then employing the MVVM pattern can make a powerful difference to your projects, reducing code and bugs in one. This book is an invaluable resource for serious developers.

  • 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

  • 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.

    Table of Contents

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