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 • 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 What is MVVM? And why do you care? MVVM Explained • Model-View-ViewModel • Data is pulled by UI, not pushed to it • Complete separation between interface and code MVVM Relationships View Model ViewModel Benefits of MVVM • Testable! • UI/UX developers can focus on their job • Cleaner, more maintainable code Getting Started What is 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 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 Slides are Pointless Let’s write some code! 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 Creating the Project • Create a new WPF application • Install Caliburn.Micro from NuGet • Configure bootstrapper Demonstration Wiring It Up • Create our first View • Create our first ViewModel • Demonstrate Data Binding and Actions Demonstration Hello, World is Boring Let’s do something real 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 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!) Demonstration User Interface • Search box • Results list • Let’s show cover art too Demonstration Holy Crap I understood all that (I think) 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 Q&A • You don’t actually have questions, do you? • Fine, I guess I’ll answer them.