Top Banner
MVVM Basics with Caliburn.Micro Presented by Stefan Nuxoll, Lithium PC
25

MVVM Basics with Caliburn.Micro

Feb 24, 2016

Download

Documents

anneke

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 Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MVVM Basics with Caliburn.Micro

MVVM Basics with Caliburn.Micro

Presented by Stefan Nuxoll, Lithium PC

Page 2: MVVM Basics with Caliburn.Micro

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

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

What is MVVM?And why do you care?

Page 5: MVVM Basics with Caliburn.Micro

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

MVVM Relationships

ViewModel

View Model

Page 7: MVVM Basics with Caliburn.Micro

Benefits of MVVM

• Testable!• UI/UX developers can focus on their job• Cleaner, more maintainable code

Page 8: MVVM Basics with Caliburn.Micro

Getting StartedWhat is Caliburn.Micro?

Page 9: MVVM Basics with Caliburn.Micro

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

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

Slides are PointlessLet’s write some code!

Page 12: MVVM Basics with Caliburn.Micro

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

Creating the Project

• Create a new WPF application• Install Caliburn.Micro from NuGet• Configure bootstrapper

Page 14: MVVM Basics with Caliburn.Micro

Demonstration

Page 15: MVVM Basics with Caliburn.Micro

Wiring It Up

• Create our first View• Create our first ViewModel• Demonstrate Data Binding and Actions

Page 16: MVVM Basics with Caliburn.Micro

Demonstration

Page 17: MVVM Basics with Caliburn.Micro

Hello, World is BoringLet’s do something real

Page 18: MVVM Basics with Caliburn.Micro

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

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

Demonstration

Page 21: MVVM Basics with Caliburn.Micro

User Interface

• Search box• Results list• Let’s show cover art too

Page 22: MVVM Basics with Caliburn.Micro

Demonstration

Page 23: MVVM Basics with Caliburn.Micro

Holy CrapI understood all that (I think)

Page 24: MVVM Basics with Caliburn.Micro

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

Q&A

• You don’t actually have questions, do you?• Fine, I guess I’ll answer them.