mvvm basics with caliburn.micro
DESCRIPTION
MVVM Basics with Caliburn.Micro. Presented by Stefan Nuxoll, Lithium PC. Overview. What is MVVM (And why do I care?) Getting Started (What is Caliburn.Micro?) Slides are Pointless (Let’s write some code!) Hello, World is Boring (Let’s do something real) Review / Q&A. Assumptions. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/1.jpg)
MVVM Basics with Caliburn.Micro
Presented by Stefan Nuxoll, Lithium PC
![Page 2: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/2.jpg)
Overview
• What is MVVM (And why do I care?)• Getting Started (What is Caliburn.Micro?)• Slides are Pointless (Let’s write some code!)• Hello, World is Boring (Let’s do something real)• Review / Q&A
![Page 3: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/3.jpg)
Assumptions
• This is an intermediate (200) level presentation• Working knowledge of C# and .Net needed• You do NOT need to know what IoC or Convention-over-
configuration mean• You do NOT need to know XAML• Though it will help
![Page 4: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/4.jpg)
What is MVVM?And why do you care?
![Page 5: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/5.jpg)
MVVM Explained
• Model-View-ViewModel• Data is pulled by UI, not pushed to it• Complete separation between interface and code
![Page 6: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/6.jpg)
MVVM Relationships
ViewModel
View Model
![Page 7: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/7.jpg)
Benefits of MVVM
• Testable!• UI/UX developers can focus on their job• Cleaner, more maintainable code
![Page 8: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/8.jpg)
Getting StartedWhat is Caliburn.Micro?
![Page 9: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/9.jpg)
What is Caliburn.Micro?
• Fully featured MVVM framework• Utilizes IoC and convention-over-configuration• Fully customizable and extremely flexible• Under 3K LoC (lean and easy to modify)• Supports WPF, Silverlight, Windows Phone and Windows RT• Available at http://caliburnmicro.codeplex.com
![Page 10: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/10.jpg)
Why use Caliburn.Micro?
• Don’t reinvent the wheel• Conventions and Actions• Built-in support for IoC (typically the MEF)• Already has support for all major .net environments
![Page 11: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/11.jpg)
Slides are PointlessLet’s write some code!
![Page 12: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/12.jpg)
Before We Begin
• Sample code and presentation are available online• We will be starting from scratch• If you’ve got Visual Studio on your laptop, feel free to follow along
![Page 13: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/13.jpg)
Creating the Project
• Create a new WPF application• Install Caliburn.Micro from NuGet• Configure bootstrapper
![Page 14: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/14.jpg)
Demonstration
![Page 15: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/15.jpg)
Wiring It Up
• Create our first View• Create our first ViewModel• Demonstrate Data Binding and Actions
![Page 16: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/16.jpg)
Demonstration
![Page 17: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/17.jpg)
Hello, World is BoringLet’s do something real
![Page 18: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/18.jpg)
Let’s Talk to Netflix
• Anyone know what Odata is?• Odata is a great idea with a so-so implementation• Somebody saw SOAP and WSDL and said “What the fuck is
this?”• Think of it as SOAP-but-better (not exactly high praise)• .Net 3.5 and higher have native support, integrates with LINQ• Netflix has an Odata endpoint, making our lives easier
![Page 19: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/19.jpg)
Okay, Let’s *ACTUALLY* Talk to Netflix
• Done complaining about Odata• Add service reference in visual studio• Create a helper class to handle querying Netflix• .Net’s Odata support works with LINQ (easy peasy!)
![Page 20: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/20.jpg)
Demonstration
![Page 21: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/21.jpg)
User Interface
• Search box• Results list• Let’s show cover art too
![Page 22: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/22.jpg)
Demonstration
![Page 23: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/23.jpg)
Holy CrapI understood all that (I think)
![Page 24: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/24.jpg)
MVVM Review
• Cleaner, more readable code• Modular, testable• Separation of UI from code• Means UI/UX developers don’t need to know jack about programming
• Pull, not push• Stop creating a ton of controls in code-behind, let the UI handle all that
![Page 25: MVVM Basics with Caliburn.Micro](https://reader033.vdocuments.mx/reader033/viewer/2022061612/56816568550346895dd7f5dc/html5/thumbnails/25.jpg)
Q&A
• You don’t actually have questions, do you?• Fine, I guess I’ll answer them.