Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tech Ed North America 2010 9/6/2019 2:07 PM Required Slide

Similar presentations


Presentation on theme: "Tech Ed North America 2010 9/6/2019 2:07 PM Required Slide"— Presentation transcript:

1 Tech Ed North America 2010 9/6/2019 2:07 PM Required Slide SESSION CODE: DEV322 Using the MVVM Design Pattern with the Microsoft Visual Studio XAML Designer Rockford Lhotka Principal Technology Evangelist Magenic Nobody’s more serious about Microsoft. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

2 Model (POCO/DTO/Entity)
MVVM View Properties Commands ViewModel Properties Methods Model (POCO/DTO/Entity)

3 Model (Rich domain objects)
MVVM (rich model) View Commands Properties ViewModel Methods/ Properties Model (Rich domain objects)

4 Why MVVM? Testing of UI code UI code structure/discipline
Separation of concerns

5 Data Storage and Management
N-Layer Architecture Interface Interface Control Object Model Data Access Data Storage and Management

6 Layered Flexibility WPF Silverlight Workflow Web XML IC IC IC IC IC
Object Model Data Access Data Access Data Access Data Access Data Access SQL DB2 WCF Oracle XML

7 Implementing the Layers
Interface Patterns Interface Control Patterns Object Model Data Access Patterns Data Storage and Management

8 The View Data binding Element binding Commanding (or similar)
Binding is important Visual Studio 2010 Blend RAD designers are important Not an MVVM goal – but a top Rocky goal  Enable better designer <-> developer interaction “No code behind”

9 The ViewModel Adds commands/verbs to the model
Triggered/invoked by the view Adds commands/verbs to the model Possibly even reshapes the model Extends the model with extra properties If the model doesn’t already support data binding Enhances the model with data binding support

10 The Model Focus is on the View and ViewModel
The Model is assumed to already exist MVVM is primarily a UI pattern Anemic Objects don’t support data binding Objects encapsulate data, rarely behavior Rich Objects support data binding Objects encapsulate behavior as well as data Types of Model

11 Connecting the Parts Drag and Drop View ViewModel Model

12 Resource Generated in View
Tech Ed North America 2010 9/6/2019 2:07 PM Resource Generated in View <UserControl.Resources> <CollectionViewSource x:Key="employeeViewModelViewSource" d:DesignSource= "{d:DesignInstance my:EmployeeViewModel, CreateList=True}" /> </UserControl.Resources> © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

13 Tech Ed North America 2010 9/6/2019 2:07 PM Code-behind???? private void UserControl_Loaded(object sender, RoutedEventArgs e) { // Do not load your data at design time. // if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) // { // //Load your data here and assign the result to the CollectionViewSource. // System.Windows.Data.CollectionViewSource myCollectionViewSource = // (System.Windows.Data.CollectionViewSource)this.Resources["Resource Key"]; // myCollectionViewSource.Source = your data // } } © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

14 ViewModel (or Presenter)
Making MVVM Work Shell Data binding & Command router View View Status Errors View factory ViewModel ViewModel ViewModel ViewModel ViewModel (or Presenter)

15 Building an App with MVVM
Tech Ed North America 2010 9/6/2019 2:07 PM Building an App with MVVM DEMO © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

16 Summary MVVM is a good pattern Avoid code-behind
MVVM requires a little “plumbing” UI shell abstraction Route View events to ViewModel verbs View factory concept

17 Thank you! Rockford Lhotka rocky@lhotka.net www.lhotka.net
Nobody’s more serious about Microsoft.

18 Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Tech Ed North America 2010 9/6/2019 2:07 PM Track Resources Visual Studio – Soma’s Blog – MSDN Data Developer Center – ADO.NET Team Blog – WCF Data Services Team Blog – EF Design Blog – © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

19 Resources Learning Required Slide www.microsoft.com/teched
Tech Ed North America 2010 9/6/2019 2:07 PM Required Slide Resources Learning Sessions On-Demand & Community Microsoft Certification & Training Resources Resources for IT Professionals Resources for Developers © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

20 Complete an evaluation on CommNet and enter to win!
Tech Ed North America 2010 9/6/2019 2:07 PM Required Slide Complete an evaluation on CommNet and enter to win! © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

21 Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st
You can also register at the North America 2011 kiosk located at registration Join us in Atlanta next year

22 Tech Ed North America 2010 9/6/2019 2:07 PM
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

23 Required Slide Tech Ed North America 2010 9/6/2019 2:07 PM
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "Tech Ed North America 2010 9/6/2019 2:07 PM Required Slide"

Similar presentations


Ads by Google