I'm trying to define a viewmodel class in the markup of my Xamarin.Forms App.xaml.
<xml version="1.0" encoding="utf-8" ?>
The Xamarin linker automatically tries to minimize the size of the app by removing libraries and classes that aren't referenced. Apparently declaring it in the XAML alone isn't enough to make the linker recognize that a reference exists (this may be a bug you should file with Xamarin). Adding a reference in App.xaml.cs forces the linker to retain it.
You can read more about the linker and its different settings here.