Chapter 2. Hello MVVM—creating a simple cross-platform app using MVVM

 

This chapter covers

  • What MVVM is and why it’s the best choice for cross-platform Xamarin apps
  • What the MVVM design pattern is all about, and why you’d want to use it to maximize your cross-platform code
  • Getting set up with Xamarin and the MvvmCross extension
  • Creating HelloCrossPlatformWorld, your first Xamarin mobile app
  • Running your app on iOS and Android

Typically at this point in a book, it’s traditional to build a Hello World app to show off the technology in question. For this book, though, I’m going to go slightly against tradition and start by discussing the MVVM (model-view–view model) design pattern. Then we’ll get our hands dirty with some code toward the end of this chapter.

We’re discussing MVVM for cross-platform Xamarin apps

The principles discussed in this chapter are for using MVVM with Xamarin apps. Although these follow the principles for MVVM on other platforms, such as desktop Windows apps or the web, there’s a lot more to it for Xamarin apps. If you’ve done MVVM before (maybe with WPF) it’s still worth reading this chapter as there are some important differences.

2.1. What are UI design patterns?

2.2. MVVM—the design pattern for Xamarin apps

2.3. What is cross-platform code?

2.4. Getting started—creating your first solution

2.5. Is this really a cross-platform app?

Summary